jquery属性选择器not has怎么写 行悬停高亮显示 |
本文标签:属性选择器,tr悬停变色 复制代码 代码如下: $(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",""); }) }) 上面代码 让一个table中没有 提交 图片的行悬停时都高亮 我先在bbs上提问: 点击打开链接 答案不满意 最后索性学一学 锋利的jquery 在附录速查手册 里找到这个 *= 和!= 分别表示包含和不包含 。 这行 复制代码 代码如下: var tr2=$("table.table_list tr:not(:has(td a img[src*=tj.gif]))"); not里面又可以放一个函数has 因为是要tr变色不是要img变色 所以不能用tr td a img[src!=tj.gif] 注意都要引号 问题:有三层引号 怎么办?还是单引号? 问题又来了tj.gif没打引号怎么也可以? 复制代码 代码如下: [src*=tj.gif 意思是src属性中包含tj.gif字符串的? 所有的也可以这样写: 复制代码 代码如下: var tr2=$("table.table_list tr").not(:has(td a img[src*=tj.gif])); 所以我怀疑 选择器 里的 : 代表调用选择器 。 下载:解压后找 main1/caiji/task_send.html即是 。 |