Those <br />s make it all more difficult, why not use proper <p>
elements?

If you wrap the colour anchors in a DIV, you can remove both "colour"
and "icon" classes, and the script gets simpler:

<div class="colours">
  <a href="#FFFFFF">
       <img src="images/icons/snowwhite.png" alt="..." />
  </a>
  <a href="#0000FF">
       <img src="images/icons/blue.png" alt="..." />
  </a>
</div>

CSS:
.colours a { ... }
.colours img { ... }

JS:
$('div.colours a:first-child img').addClass('selected');

Also why not put the image away and use a background-color for the
anchor itself?

(sorry for being so meddlesome)

- ricardo

On Jan 8, 9:53 am, Martynas Brijunas <[email protected]> wrote:
> >   $('.description img:eq(0)').addClass('icon_selected') // add class to the
> > 1st image element whitin div.description
>
> Now it selects the first image of the first div only. I have updated
> the test website with your change.
>
> Martin

Reply via email to