<strong>效果如图所示:</strong><br><img src="http://files.jb51.net/upload/201005/20100526201829788.gif" border="0" alt="jquery css 选择器演示代码_jquery" ><br><strong>核心代码:</strong><br><div class="codetitle"> <span><a style="CURSOR: pointer" data="88506" class="copybut" id="copybut88506" onclick="doCopy('code88506')"><u>复制代码</u></a></span> 代码如下:</div> <div class="codebody" id="code88506"> <br><script type="text/javascript"> <BR>$('#one').css("background","#fff"); <BR>$('div').css("background","#fff"); <BR>$('body div').css("background","#bbffaa");//改变body内所有div的属性 <BR>$('div > span').css("background","#bbffaa").css("color","red").css("font-size","12px");//改变所有div下的span元素的属性 <BR>$('#two >.mini').css("background","red");//id为two的div内的所有class为mini的元素的属性 <BR>$('#two').siblings("div").css("color","green");//选取#two同辈的div元素,无论前后位置 <BR>$('div:first').css("background","red"); <BR>$('div:gt(1)').css("background","#fff");//索引值大于1的所有div元素 <BR>$('div:lt(1)').css("background","yellow"); <BR>$('div:not(.one)').css("color","#cccccc");//改变class不为one的div元素 <BR>$('div:even').css("font-size","15px");//索引号为偶数的div <BR>$('div:odd').css("font-size","12px");//索引号为奇数的div <BR>$('div:contains(other)').css("font-size","10px");//设置含有文本other的div元素 <BR>$('div:has(.mini)').css("color","#bbffaa");//设置含有class为mini元素的<div>元素的背景色 <BR>$('div:parent').css("color","#ffcccc");//改变含有子元素(包括文本)的div元素的属性 <BR>$('div:hidden').show(3000);//获取隐藏的div <BR>$('div:visible')//获取可见的div <BR>$("div[title=test]").css("background","black");//设置title为test的div <BR>$("div[.mini][title=test]").css("color","red");//设置class为mini title为test的div <BR></script><br> </div> <br>完全演示代码:<br><div class="htmlarea"><textarea id="runcode96792"> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> <title>jquery css </title></textarea></div>