zl程序教程

您现在的位置是:首页 >  前端

当前栏目

jquery属性选择器nothas怎么写行悬停高亮显示

jQuery属性 怎么 显示 选择器 高亮 悬停
2023-06-13 09:15:11 时间
复制代码代码如下:

$(function(){
/*
//$("htmlbodydivtable.table_listtbodytr").not(":has("tdaimg[src*=tj.gif]")").mouseover(function(){
$("htmlbodydivtable.table_listtbodytr:not(":has("tdaimg[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="";
});
});
*/
vartr2=$("table.table_listtr:not(":has("tdaimg[src*=tj.gif]")")");
tr2.mouseover(function(){
$(this).css("backgroundColor","66CCFF");
})
tr2.mouseout(function(){
$(this).css("backgroundColor","");
})
})

上面代码让一个table中没有提交图片的行悬停时都高亮

我先在bbs上提问:点击打开链接

答案不满意最后索性学一学锋利的jquery在附录速查手册里找到这个*=和!=分别表示包含和不包含。

这行
复制代码代码如下:

vartr2=$("table.table_listtr:not(":has("tdaimg[src*=tj.gif]")")");

not里面又可以放一个函数has因为是要tr变色不是要img变色所以不能用trtdaimg[src!=tj.gif]注意都要引号问题:有三层引号怎么办?还是单引号?

问题又来了tj.gif没打引号怎么也可以?
复制代码代码如下:
[src*=tj.gif

意思是src属性中包含tj.gif字符串的?

所有的也可以这样写:
复制代码代码如下:
vartr2=$("table.table_listtr").not(":has("tdaimg[src*=tj.gif]")");

所以我怀疑选择器里的:代表调用选择器。

下载:解压后找main1/caiji/task_send.html即是。