开发者

How to select all links whose protocol is not http with jQuery?

开发者 https://www.devze.com 2022-12-08 02:30 出处:网络
Suppose that you have: <a href=\"file://...\">link1</a> <a href=\"file://...\">link2</a>

Suppose that you have:

<a href="file://...">link1</a>
<a href="file://...">link2</a>
<a href="http://...">link3</a>
<a href="http://...">link4</a>

What code should I use to select only 开发者_如何学编程link1 and link2 without using a[href^=http]?


That's exactly how you would do it:

$('a:not(a[href^=http])')

or

$('a[href^=file]')

What's wrong with selecting based on the href attribute?

0

精彩评论

暂无评论...
验证码 换一张
取 消