使用jQuery重新排序图像

See*_*See 2 jquery jquery-ui image jquery-plugins

我有4个并排坐着的小缩略图,单击它们时会在它们下面更改一个小div /面板,以显示不同的文本。

单击图像后,我希望它们按单击到最左端的图像重新排序。因此,如果在下面单击2:

1 2 3 4

它应该变成

2 1 3 4

理想情况下是滑动的,我发现有很多Jquery UI插件可以显示滑动的carasols等,但没有一个可以对图像进行重新排序,有没有人知道?

谢谢

kei*_*kei 5

干得好。:D

http://jsfiddle.net/rNzf7/

$(document).ready(function() {
    var x = 100;
    $('img').each(function() {
        $(this).css("left",x+"px");
        $(this).css("background-color", "rgb(0,90,"+x+")");
        x += 55;
    });
});

$('img').click(function(e) {
    
 
    $(e.target).animate({
        left: "100"
    });
    
    $(e.target).siblings().each(function (){
        if ( $(this).position().left < $(e.target).position().left ) {
            $(this).animate({ left: "+=55" });
        }
    });
});
Run Code Online (Sandbox Code Playgroud)