There is a list of

<ul> <li><a href="link1"><img src="img01.jpg"></a></li> <li><a href="link2"><img src="img02.jpg"></a></li> <li><a href="link3"><img src="img03.jpg"></a></li> <li><a href="link4"><img src="img04.jpg"></a></li> </ul> 

When you click on any link in the list, for example, the third, a div added to which the images in the src are written, the href links is written, and the image class="clicked" order of the clicked link is added to the class="clicked" . Like this:

 <div class="new div"> <img src="link1"> <img src="link2"> <img src="link3" class="clicked"> <img src="link4"> </div> 

How to implement it on jQuery? Here is the fiddle

  • one
    for starters, I would advise to refuse links, so as not to kill a click on the link - Gedweb
  • OK, and how to continue to display a list of images? - alteste

1 answer 1

Look in the direction of the DOM , click hang through jQuery (so cross-browser). In the handler function, this is the element that was clicked on.

See the createElement , appendChild , setAttribute You can of course on jQuery, but cramming html with strings is evil.