Jes*_*ton 4 javascript css css-selectors css3 selectors-api
我正在尝试使用该querySelectorAll()方法来获取网页中的链接,但我想忽略以"javascript:"开头的链接或使用其他协议,例如"itpc://"
有没有办法将这些包含在"not()"伪选择器中?
document.querySelectorAll("a:not([href^=javascript]):not([href^=itpc])"); //works
document.querySelectorAll("a:not([href^=javascript:]):not([href^=itpc://])"); //doesn't work
Run Code Online (Sandbox Code Playgroud)
即使第一种方法在当前页面上工作正常,也无法保证它将在我将使用它的每个页面上都能正常工作,所以我真的希望能够检测到该冒号.
Jon*_*Jon 11
document.querySelectorAll("a:not([href^='javascript:']):not([href^='itpc://'])");
Run Code Online (Sandbox Code Playgroud)
您当前版本的问题在于,除非您使用引号,否则值必须符合对标识符的限制,否则它们不会.
| 归档时间: |
|
| 查看次数: |
3176 次 |
| 最近记录: |