Skip to content Skip to sidebar Skip to footer

A:not(a:not([href])) Selector

I want that a certain action to be associated to the click event of the anchor tag whenever its href attribute: does not start with mailto: and does not end with # and is present

Solution 1:

[href] means there is an href attribute no matter which, if any, value it has.

As pimvdb correctly pointed out, you could use

a[href]:not([href^="mailto\\:"], [href$="\\#"])

Which means "all a elements with any href attribute, except those whose href attribute starts with mailto: or ends with #


Post a Comment for "A:not(a:not([href])) Selector"