Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to select anchor tag with specified class and rel?

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?

like image 922
daGrevis Avatar asked Jul 27 '11 06:07

daGrevis


People also ask

Can we use class in anchor tag?

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.

How do I select an anchor tag inside a div?

To find anchor tag in div, use a selector and the addClass() method adds a class using jQuery.

Can we set value in anchor tag?

To do that, you can use the ping attribute of the anchor tag. A ping attribute accepts one or more URLs as values.


1 Answers

You can use something like:

$('a.foo.bar[rel="123"]')
like image 101
Qtax Avatar answered Sep 18 '22 12:09

Qtax