1

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. Is the word 'class' reserved in IE, or what can be the problem, and what is the solution?

1
  • have you tried with a['class']? Commented Sep 24, 2011 at 14:17

1 Answer 1

3

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']);
Sign up to request clarification or add additional context in comments.

1 Comment

@Tamas Pap, glad I could help. Is there something else you would like to ask?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.