javascript - populate newly added textbox with last texbox value -
how can populate newly added begin_date textbox last end_date ?
$('body').on('focus', ".dpicker", function () { $(this).datepicker(); });
jsfiddle here
if need functional after more 1 form addition
add class additem link
<a href="#" id="additem" class="additem">add</a>
modify click handler able listen newly added links
$(document).on('click', '.additem', function () {...}
and add input field value update on appending of new form block
$(document).on('click', '.additem', function () { var last_date; $.ajax({ url: this.href, cache: false, success: function (html) { last_date = $('.deleterow:last .forminput:last input').val(); $("#editorrows").append(str); $('.deleterow:last .forminput:first input').val(last_date); } }); return false; });
demo here http://jsfiddle.net/mandarin6b0/ow0gsnvs/9/
p.s. try rid of multiple identical id. (i.e. id="#additem")
Comments
Post a Comment