Hello,
I am looking for some guidance on how to achieve a simple objective. I
have multiple <DIV> elements on a page, and within each <DIV> there
are 4 <A> elements. Within each <A> there is an <IMG>. My goal is to
apply a class to each of these <IMG> upon rendering the page.
<div class="description">
<a class="colour" href="#"><img class="icon" src="/images/icons/
snowwhite.png" alt="Snow White"></a>
<a class="colour" href="#"><img class="icon" src="/images/icons/
deepcream.png" alt="Deep Cream"></a>
<a class="colour" href="#"><img class="icon" src="/images/icons/
mistygrey.png" alt="Misty Grey"></a>
<a class="colour" href="#"><img class="icon" src="/images/icons/
paleivory.png" alt="Pale Ivory"></a>
</div>
I have tried using $("div.description a.colour:first-child
img.icon").addClass("icon_selected"); but that does not work.
Please help as I am going round in circles. Thank you.
Best regards,
Martin