Possible Duplicate:
Jquery clone of a textbox without the content
I use .clone in jQuery. When I clone ul it is cloning its value also. I only want to copy structure not value. When you type some value in input field and then click clone it will clone input value too.
<div class="str">
<ul><li><input type="text" /></li></ul>
</div>
<a href="#">clone</a>
$(function() {
$('a').live('click', function() {
var cln = $('ul:last').clone();
$('.str').append(cln);
});
});
You can try the code below. By the way, if you use the last version of jQuery I’d suggest using
onmethod instead oflive(here instead ofbodyyou can use any parent ofaelement).DEMO: http://jsfiddle.net/vhq5p/18/