I have a with textbox , on cloning it ,I am able to change id of div but unable to change id of textbox inside div..
var toAddCloneCount = 0; function AddDestination() { var clone = $("#toAdd").clone(true); clone.find('textbox').attr('id', 'days' + toAddCloneCount); clone.show(); clone.attr('id', 'toAdd' + toAddCloneCount++).insertAfter("#toAdd"); clone.appendTo("#destinations"); }
textbox
is not a valid html element. Did you mean textarea
? Or maybe input[type=text]
? You should be using .prop() if you are using jQuery 1.6+
Try
clone.find('textarea').prop('id', 'days' + toAddCloneCount);
OR
clone.find('input[type=text]').prop('id', 'days' + toAddCloneCount);
尝试这个:
clone.find('#toAdd').prop('id', 'days' + toAddCloneCount);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.