Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery select elements that match class and attribute?

Tags:

jquery

I'm currently selecting all elements with class .follow-container, this is the code:

$('.follow-container').html('it's this one');

How do I only select elements that have the class and also the attribute onmousedown="alert()"

like image 635
lisovaccaro Avatar asked Apr 14 '26 18:04

lisovaccaro


2 Answers

$('.follow-container[number="3"]')
like image 133
kei Avatar answered Apr 17 '26 08:04

kei


Just to mention but you should really use a data attribute instead of an unsupported number attribute.

What about data-number="3" instead?

You could then select this using:

$('.follow-container[data-number="3"]');

If you would prefer to use your attribute you could use:

$('.follow-container[number="3"]');
like image 20
Undefined Avatar answered Apr 17 '26 07:04

Undefined



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!