I don't understand clearly what does this code mean ?
a[href*=#]:not([href=#])
Thank you !
Simply:
a[href*=#]
gets all anchors (a
) that contain #
in href.
But with:
:not([href=#])
excludes anchors with href exactly equal to #
.
Example:
<a href="#step1">yes</a>
<a href="page.php#step2">yes</a>
<a href="#">no</a>
the selector gets the first two anchors, but it excludes the last.
For more details you can consult the attribute selectors chapter
Just in case anyone had the same problem as me with it and new version of jQuery :
The solution is not to use a[href*=#]:not([href=#])
but
a[href*="#"]:not([href="#"])
This was a breaking change in jQuery 2.2.4 onwards.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With