在悬停框中更改文本的颜色

时间:2022-06-04 08:11:16

I have a table and different fields in the table will change font color depending on if a flag is flipped. I have several flags with different colors that might be flipped at any time.

我有一个表,表中的不同字段将根据是否翻转标志更改字体颜色。我有几个不同颜色的标志,可以随时翻转。

I wanted to include a hover over text that had the name of the exception caused by the flag and in the same color as the flag.

我希望将鼠标悬停在文本上,该文本具有由标志引起的异常名称,并且与标志颜色相同。

(I was originally going to include a little square of color next to the name but this seems difficult/impossible WITHIN a hover, so now I'm just trying to change the text color).

(我原本打算在名称旁边加一个小方块,但这似乎很难/不可能在悬停中,所以现在我只是想改变文字颜色)。

I cannot get this to work. help?

我不能让这个工作。救命?

my flags are:

我的旗帜是:

flag1, if true then the field shows in red for exception1
flag2, if true then the fields shows in blue for exception2
flag3, if true then the fields shows in green for exception3

javascript/jquery:

if($flag1 === true){            
    $flag1.css("color", "red");
    $(".myTable").attr('title', 'exception1').css("color","red");
}else if($flag2 === true){              
    $flag2.css("color", "blue");
    $(".myTable").attr('title', 'exception2').css("color","blue");
}else if($flag3 === true){              
    $flag3.css("color", "green");
    $(".myTable").attr('title', 'exception3').css("color","green");
}

however, trying to color the text that shows up INSIDE THE HOVER, isn't working. it's just coloring more of the table's fields. How can I color the text inside the hover instead of it's default black color?

然而,尝试着色显示在INSIDE THE HOVER中的文本是不起作用的。它只是为表格的字段着色。如何为悬停内的文本着色而不是默认的黑色?

As a side note, if it's just as easy to put a block of color next to the text instead of coloring the text, please let me know about this as well. I cannot seem to find a solution for either.

作为旁注,如果在文本旁边放置一块颜色而不是为文本着色同样容易,请告诉我这一点。我似乎无法找到解决方案。

please see fiddle for simple example. http://jsfiddle.net/L3e1ff3g/

请看小提琴的简单例子。 http://jsfiddle.net/L3e1ff3g/

1 个解决方案

#1


0  

First of all in your if/else you are checking every-time ($flag1 === true) I think it should be

首先在你的if / else中你每次都在检查($ flag1 === true)我认为它应该是

if($flag1 === true){   
...
}else if($flag2 === true){
...
}else if($flag3 === true){

About second question - please provide your html

关于第二个问题 - 请提供您的HTML

#1


0  

First of all in your if/else you are checking every-time ($flag1 === true) I think it should be

首先在你的if / else中你每次都在检查($ flag1 === true)我认为它应该是

if($flag1 === true){   
...
}else if($flag2 === true){
...
}else if($flag3 === true){

About second question - please provide your html

关于第二个问题 - 请提供您的HTML