您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

jquery怎么查找不含某个属性的元素

2025/4/22 6:14:21发布18次查看
查找方法:1、利用“:not()”和“[attribute]”选择器,语法“$(元素:not([attribute]))”;2、利用not()方法和“[attribute]”选择器,语法“$(元素).not([attribute])”。
本教程操作环境:windows7系统、jquery1.10.2版本、dell g3电脑。
在jquery中,想要查找含某个属性的元素,需要使用属性选择器[attribute]。
而查找不含某个属性的元素,就需要组合一个否定选择器“:not()”或 not()方法。
语法:
:not([attribute])not([attribute])
示例:
<!doctype html><html> <head> <meta charset="utf-8"> <script src="js/jquery-1.10.2.min.js"></script> <script type="text/javascript"> $(document).ready(function() { $("li:not([id])").css("background-color", "#b2e0ff"); $("li").not("[class]").css("background-color", "#ff0307"); }); </script> </head> <body> <html> <body> <div id="choose"> who is your favourite: <ul> <li id="li1">goofy</li> <li id="li2" class="li">mickey</li> <li class="li">pluto</li> </ul> </div> </body> </html> </body></html>
相关教程推荐:jquery视频教程
以上就是jquery怎么查找不含某个属性的元素的详细内容。
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product