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 

here's updated (working) fiddle


Comments

Popular posts from this blog

c++ - CryptStringToBinary API behavior -

java.util.scanner - How to read and add only numbers to array from a text file -

iphone - Three second countdown in cocos2d -