How can I change the ID of a cloned element using jQuery? -
i trying clone fieldset in form, , append @ end of others existing fieldset after renaming fieldset's legend, , input fields.
everything working fine, except change of cloned fieldset id.
either try change id via
item.children('fieldset[id^="block_"]:first').attr('id', 'block_'+max_index); or via
item.children('fieldset').attr('id', 'block_'+max_index); the fieldset id remains unchanged ?!
i've done small piece of code illustrate problem : http://jsfiddle.net/levure/4jk5t/
where mistake ? many in advance tips !
in code, item refers fieldset, line :
item.children('fieldset').attr('id', 'block_'+max_index); // <-- not work should become :
item.attr('id', 'block_'+max_index); // <-- work
Comments
Post a Comment