Internet Explorer has some problems with handling JavaScript reserved keywords when these appear within a jQuery method. For example, suppose that you want to set a CSS class using the attr()
method, like so:
$(element).attr({id: 'Test', class: 'Test'});
IE will simply throw an error, because class
is a reserved word in JavaScript. To avoid this problem, you can either enclose the keyword between quotes or using another approach (in this case you can use addClass()
).
for this case, I think attr({'id': 'Test', 'class': 'Test'}); still work well
did you try it?
yeah, it works. :-)