请帮助我,我一般知道如何使用可拖动和可放置类,但我找不到实现这一点的方法:
我有一个大尺寸的图像,我需要将其拖放到一个 div 中。
1)拖拽的时候,不是在大图左右移动,而是想用小图(我已经有了,只需要改src)。
2)一旦它到达目标div,我想隐藏那个拖动的图像并在原来的位置再次显示大尺寸的图像。
唯一的限制是:必须应用“revert: invalid”。
这是我的代码:
$("#big_img").draggable({
revert: 'invalid',
drag : function(e, ui){
//Change big image with a small version of it
$(this).attr("src").replace("/Large/","/Small/"); //<--this do nothing
}
});
$("#target").droppable({
drop: function(e, ui) {
alert("was added"); //<-- no problem here.
//Restore the big_img
}
});
谢谢你。