Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我的页面上有链接。如何获取除 # 和 javascript:void(0) 之外的所有链接?
您可以使用.not()以选择器开头的 and 属性^=来获取您要查找的元素:
.not()
^=
$( "a:not( [href^='#'], [href^='javascript:void'] )");
此查询将搜索属性不以井号 ( ) 或字符串开头a的所有元素。href#javascript:void
a
href
#
javascript:void
参考: