See See - 6 months ago 10
Javascript Question

Reorder images using jquery

I have 4 small thumbnail images sitting side by side which when clicked upon each change a small div/panel underneath them to show different text.

When the image is clicked I want them to reorder by the one that was clicked to go to the far left. So if 2 was clicked below:

1 2 3 4

It should become

2 1 3 4

Ideally sliding, i found lots of Jquery UI plugins to show sliding carasols etc but none to reorder images, any know of any?

Thanks

Answer

This is what you are looking for (no sliding as noticed by neal).

$('img-selector').click(function(){
  $(this).parent().prepend(this);
});

colorful demo at http://jsfiddle.net/gaby/Lu5Q8/