[英]Javascript Help - If a certain text is found, change text color
I'm looking for some help changing the code below to do not apply the second color if the text is not found.如果找不到文本,我正在寻找一些帮助来更改下面的代码以不应用第二种颜色。 I intent to use the code more the once with other text according to the colors I and to change:我打算根据我的颜色将代码与其他文本一起使用一次并更改:
$(document).on('knack-view-render.any', function(event, view, data)
{
$("td.field_1416 > span , td.field_1416 > span > i").each(function()
{
var cordaequipeROSA = ($(this).find("span").text().trim() == "Equipe Rosa") ? "#ff00ee" : "#a4b7c9";
$(this).css("color", cordaequipeROSA);
})
});
I want to remove the second color option an duplicate the code with other atributes, like this:我想删除第二个颜色选项,将代码与其他属性重复,如下所示:
$(document).on('knack-view-render.any', function(event, view, data)
{
$("td.field_1416 > span , td.field_1416 > span > i").each(function()
{
var cordaequipeBRANCA = ($(this).find("span").text().trim() == "Equipe BRANCA") ? "#fff" : "#a4b7c9";
$(this).css("color", cordaequipeBRANCA);
});
});
Does anyone know what should I change in the code to apply only one color per ($(this).find("span").text().trim() == "SEARCH_CRITERIA") ?有谁知道我应该在代码中更改什么以使每个 ($(this).find("span").text().trim() == "SEARCH_CRITERIA") 只应用一种颜色?
Thanks!谢谢!
<input id="textbox">
<script>
function changecolor()
{
if textbox.value === "TEXT THAT SHOULD CHANGE COLOR")
{
document.getElementById("textbox").style.color = 'THE COLOR THAT IT CHANGES TO';
}
else
{
document.getElementById("textbox").style.color = 'black';
}
}
document.addEventListener('keyup', (event) => changecolor(), false)
</script>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.