开发者

How to append div with div's inside using jquery?

I have a div with all kinds of div's inside. If i append them only the first one is draggable. Do i have to use append parent for开发者_StackOverflow this or something else?

Here is a jsfiddle of my problem;

http://jsfiddle.net/nNzkr/


You have multiple divs with the same id. That's invalid HTML.

Also note that you're appending your new div elements to the one that handles the click event and creates new ones.

You'll have to call .draggable(...) on each div as they are created.


Here is your example with each element draggable.

http://jsfiddle.net/nNzkr/1/

$("#duplicate").click(function() {
    var html = $(elem);
    $("#wrap").append(html);
    html.draggable({});
});
$('.draggable').draggable({});

var elem = '<div class="draggable"><div></div></div>';
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜