本篇看看not()、is()和:not()的区别。not()删除与指定表达式匹配的元素,is()检查元素是否匹配指定的选择器,返回false或true,:not()和not()相似,不同点在于可以在选择中使用它。
<p class="not">
this is a test.
</p>
<p id="test">jQuery学习</p>
$(document).ready(function() {
//输出"jQuery学习"
alert($("p").not(".not").text());
//$("#test")[0]转为dom对象
//输出"this is a test"
alert($("p").not($("#test")[0]).text());
//返回true
alert($("p").is(".not"));
//输出jQuery学习
alert($("p:not(.not)").text());
});