I have some images, all of which have alt tags.
I am trying to add a class to all images that have a specific alt tag.
So, to express this in simple terms:
If the image is alt tag = "dog", then add the class "canine"
alt
Any ideas?
thanks
You can use the attribute equal to the selector and addClass :
$("img[alt='dog']").addClass("canine");
or you can use
$("img[alt*='dog']").addClass("canine");
include any image with alt containing dog .
dog
$('img[alt="dog"]').addClass("canine")
it is very simple ...
notetoself: type faster ...;)