Reputation: 3486
I want to be able to hide all elements which have an ALT value of 3
using jquery.
hide all elements with attribute alt="3"
Is this possible? And if so, how can it be done?
Thanks
Upvotes: 1
Views: 562
Reputation: 101473
Try this:
$('[alt="3"]').hide();
It uses the attribute selector to match elements where alt
has a value of 3
.
hide()
, obviously, hides all matched elements. To narrow the selector down (and make it a bit faster), you can always add the tag name as usual:
$('div[alt="3"]').hide();
For dynamic values, you can use ordinary string concatenation:
var theValue = 3;
$('div[alt="' + theValue + '"]').hide();
Upvotes: 5