Select anchors without href

I would like to change the css style of all anchors without attribute href.

I can use the selector to select anchors that start with something using $('a[href^="some_link"]'). But I want it to be the other way around. How can I select bindings without href using jquery?

Also, can I achieve this with the css selector?

Thank.

+5
source share
2 answers

You need this selector (jQuery / CSS compatible):

a:not([href])

If you need IE support (because of this :not()), use it as a jQuery selector. Otherwise, you can use it for a CSS rule.

+14
source

$("a").filter(function() { return !this.attributes['href']; }).

, , Sizzle ( querySelectorAll).

http://jsfiddle.net/9PWQB/

+1

All Articles