开发者

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

开发者 https://www.devze.com 2023-01-13 16:12 出处:网络
When passing the contents of a <div> to another <div> with jquery as b开发者_如何学运维elow, the original is removed.

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

精彩评论

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