Using attribute selectors in jQuery means you can easily find HTML web page elements without manually finding the elements inside the HTML which can often be like finding a needle in a haystack.
The beauty of these special selectors is that a simple jQuery attribute selector line can find and select several HTML elements all at the same time! Magic.
Here is how you do it:
$("[href]") //select all elements with an href attribute. $("[href='#']") //select all elements with an href value equal to "#". $("[href!='#']") //select all elements with an href attribute NOT equal to "#". $("[href$='.jpg']") //select all elements with an href that ends with ".jpg".
Sam Deering has 15+ years of programming and website development experience. He was a website consultant at Console, ABC News, Flight Centre, Sapient Nitro, and the QLD Government and runs a tech blog with over 1 million views per month. Currently, Sam is the Founder of Crypto News, Australia.
Your First Year in Code
Visual Studio Code: End-to-End Editing and Debugging Tools for Web Developers
Jump Start Git, 2nd Edition