jquery addclass if image has specific alt tag

javascript, jquery

Solution

You can use the attribute equals selector and addClass method:

$("img[alt='dog']").addClass("canine");

Problem

I have some images, all of which have alt tags. I am trying to add a class to all of the images which have a certain alt tag. So to put it in plain terms: If image `alt` tag = "dog" then add class "canine" Any ideas? thanks

Original source