标签:javascript jquery
});
下面是一个代码例子:判断有背景颜色的元素,并将它们的背景颜色全部改为黑色。
<html> <head> <title></title> <style type="text/css"> .c1{ background-color: yellow; } .c2{ background-color: green; } p{ background-color: pink; } h3{ background-color: gray; } </style> </head> <body> <div class="c1">Bye Bye Beautiful</div> <div class="c2">Nothing but the girl</div> <p>The Lazy song</p> <h2>If I die young</h2> <h3>New soul</h3> <script type="text/javascript" src="jquery.2.0.3.js"></script> <script type="text/javascript"> jQuery(document).ready(function($) { var ret = $('*').filter(function(index) { return !$(this).css('background-color'); }); $.each(ret, function(index, val) { $(val).css('background-color','black'); }); }); </script> </body> </html>
jQuery 选择具有特殊属性的元素,布布扣,bubuko.com
标签:javascript jquery
原文地址:http://blog.csdn.net/lcstrive/article/details/30712375