Home >Web Front-end >JS Tutorial >How to write jquery attribute selector not has row hover highlight_jquery

How to write jquery attribute selector not has row hover highlight_jquery

WBOY
WBOYOriginal
2016-05-16 17:15:281708browse
Copy code The code is as follows:

$(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 above code allows rows in a table that do not submit images to be highlighted when hovering

I First ask the question on bbs: Click to open the link

If you are not satisfied with the answer, you can finally learn the sharp jquery and find this *= and = in the appendix quick reference manual to indicate inclusion and exclusion respectively. Contains.

This line
Copy the code The code is as follows:

var tr2 =$("table.table_list tr:not(':has('td a img[src*=tj.gif]')')");

not can put another function inside has Because you want tr to change color and not img to change color, you cannot use tr td a img[src!=tj.gif] Note that both quotes are required: What should I do if there are three layers of quotes? Or single quotes?

The problem comes again. How can tj.gif be used without quotation marks?
Copy code The code is as follows:

[src*=tj.gif

Meaning that the src attribute contains the tj.gif string?

All can also be written like this:
Copy the code The code is as follows:

var tr2=$("table.table_list tr").not(':has('td a img[src*=tj.gif]')');

So I doubt the selection In the selector: means calling the selector.

Download: After unzipping, look for main1/caiji/task_send.html.
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn