Friday, April 6, 2012

jQuery Newbie Mistake

I just made a jQuery newbie mistake but the worst part about it was that the code still worked in all browsers...except IE7. So I didn't even know that I had done it wrong until one of the developers discovered it.

Here is what I tried to do:

$("blah").each(function(index) {
this.id = newID;
this.name = newID;
});
Here is what I should have done:

$("blah").each(function(index) {
$(this).attr("id", newID);
$(this).attr("name", newID);
});
Once I changed my code to the latter, it starting working correctly in IE7.

0 comments:

Post a Comment

 
Blogger Templates