一、filter爲過濾方法,過濾出想要選擇的元素javascript
描述:選中class類名爲box的div並添加背景色紅色css
<body> <div class="box">div1</div> <div>div2</div> </body> <script type="text/javascript"> $('div').filter('.box').css('background','red') </script>
執行效果、:java
二、not方法和filter方法相反spa
<body> <div class="box">div1</div> <div>div2</div> </body> <script type="text/javascript"> $('div').not('.box').css('background','red') </script>
執行效果:code
三、has:包含blog
描述:查找包含span標籤的divip
<body> <div class="box"><span>div1</span></div> <div>div2</div> </body> <script type="text/javascript"> $('div').has('span').css('background','red') </script>
執行結果:class