I have an anchor tag like this, and I need to select it!
<a href="#" class="foo bar" rel="123">...</a>
Is it possible with jQuery to write a selector that selects an anchor that has class like foo bar
and rel like 123
?
To add a class on click of anchor tag, we use addClass() method. The addClass() method is used to add more property to each selected element. It can also be used to change the property of the selected element.
To find anchor tag in div, use a selector and the addClass() method adds a class using jQuery.
To do that, you can use the ping attribute of the anchor tag. A ping attribute accepts one or more URLs as values.
You can use something like:
$('a.foo.bar[rel="123"]')
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