Joh*_*ohn 6 html css jquery jquery-ui
我使用jQueryUI可排序,我有两个列表:
当从添加拖动到删除时,我希望div .container背景颜色变为红色.
然后当从删除拖动到添加时,我希望div .containerTwo背景颜色变为红色.
$("#gallery").sortable({
connectWith: "#trash"
});
$("#trash").sortable({
connectWith: "#gallery"
});
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?谢谢
您可以使用receive事件来响应列表收到项目的时间:
查看更新的小提琴:http://jsfiddle.net/w3vvL/39/
$("#gallery").sortable({
connectWith: "#trash",
receive: function(event, ui) {
$(".container").css("background-color", "red");
}
});
Run Code Online (Sandbox Code Playgroud)
并使用动画:
$("#gallery").sortable({
connectWith: "#trash",
receive: function(event, ui) {
$(".container").css("background-color", "green");
$(".container").stop().animate({ backgroundColor: "white" }, "slow");
}
});
Run Code Online (Sandbox Code Playgroud)
查看更新的小提琴:http://jsfiddle.net/w3vvL/43/