Javascript Json problem in IE9
Hy guys. In firefox and chrome this script alerts 'myclass', but does nothing in IE (i have version 9).
var a = {"class" : "myclass"};
alert(a.class);
if I use cssclass instead of class, it is working in IE too.
var a = {"cssclass" : "myclass"};
alert(a.cssclass);
This is very annoying. I开发者_如何学Gos the word 'class' reserved in IE, or what can be the problem, and what is the solution?
I think class
is a reserved keyword. Because objects are associative arrays in javascript you could also use this to access the value:
alert(a['class']);
精彩评论