I am trying to clone a div and change the names of the input fields in this div. It works great for most of the browsers but IE 7 does not change the name attribute of the i
try this ( raw code)
$(some_cloned_element).each(function(i, elem){
var newName = "yay_i_love_my_new_name";
if ($.browser.msie === true){ // evil browser sniffing *cries*
$(elem).replaceWith(document.createElement(
this.outerHTML.replace(/name=\w+/ig, 'name='+newName+'_'+i)
));
} else {
$(elem).attr('name',newName+'_'+i);
}
$("body").append(some_cloned_element);
});
check when i=50 and then break/exit
better way : use name as array like name=picture[]
Refernece