开发者

get src from draggable img

i have this little code to drag & drop images:

$("img").draggable({
    revert: true,
    opacity: 0.7,
    cursor: "move",
    cursorAt: {
        cursor: "crosshair",
        top: -5,
        left: -5
    }
});

$('#mybox').droppable({
    drop: function () {
        $(this).append('<div style="float:left;"><img src="http://dummyimage.com/42x40/000/fff.jpg"></div>');
    }
});

the idea is: when I drag a image, instead of show the dummy image, show开发者_开发知识库 the image itself, but how i can get the src from image from draggable. Any Idea?

Thanks in advance.


Try this code:

***
$('#mybox').droppable({
    drop: function (event, ui ) {
        $(this).append('<div style="float:left;"><img src="'+ ui.draggable.attr('src') +'"></div>');
    }
});
***
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜