开发者

Jquery - passing a duplicate of a <div> to another

When passing the contents of a <div> to another <div> with jquery as b开发者_如何学运维elow, the original is removed. Is there a way to do this and still retain the original?

Example Here - I want the document to read Item One, Item Two, Item One.

   function display() {
    $('#display').html($('#ItemOne'));
}

display();


use clone()

http://docs.jquery.com/Clone

function display() {
    $('#display').html($('#ItemOne').clone());
}

display();


 $('#display').html($('#ItemOne').html());

add .html()


Change to

function open() {
    $('#display').html($('#ItemOne').clone());
}

See: jsfiddle

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜