Jquery attribute selector not has how to write line hover highlighting
- 2020-03-29 23:45:01
- OfStack
$(function(){
/*
//$("html body div table.table_list tbody tr").not(":has('td a img[src*=tj.gif]')").mouseover(function(){
$("html body div table.table_list tbody tr:not(':has('td a img[src*=tj.gif]')')").mouseover(function(){
//alert($(this)[0].style.backgroundColor);
$(this).css("backgroundColor","66CCFF");// "red" "#f8fbfd"
$(this).mouseout(function(){
$(this).css("backgroundColor","");//$(this)[0].style.backgroundColor="";
});
});
*/
var tr2=$("table.table_list tr:not(':has('td a img[src*=tj.gif]')')");
tr2.mouseover(function(){
$(this).css("backgroundColor","66CCFF");
})
tr2.mouseout(function(){
$(this).css("backgroundColor","");
})
})
The code above makes all lines in a table that have not submitted images highlighted when hovering
My first question: on the BBS (link: http://bbs.csdn.net/topics/390639863)
The answer is not satisfactory. Finally, learn the sharp jquery in the appendix quick reference manual to find this *= and! = contains and does not contain, respectively.
This line
var tr2=$("table.table_list tr:not(':has('td a img[src*=tj.gif]')')");
You can also put a function has in not because you want tr to change color instead of img to change color so you can't use tr td a img[SRC!=tj.gif]. Single quotation marks?
Here's the problem again. Tj.gif is okay without quotes.
[src*=tj.gif
SRC property that contains the tj.gif string?
All of them can also be written like this:
var tr2=$("table.table_list tr").not(':has('td a img[src*=tj.gif]')');
So I suspect that the selector in the: represents the call selector.
Download: unzip it and go to main1/caiji/ task_sentence.html.