Response title
This is preview!
"id": "file",Hope that helps you.
"value": "File",
"popup": {
"menuitem": [
{"value": "New", "onclick": "CreateNewDoc()"},
{"value": "Open", "onclick": "OpenDoc()"},
{"value": "Close", "onclick": "CloseDoc()"}
]
}
},
"menu2": {
"id": "file2",
"value": "File2",
"popup": {
"menuitem": [
{"value": "New", "onclick": "CreateNewDoc()"},
{"value": "Open", "onclick": "OpenDoc()"},
{"value": "Close", "onclick": "CloseDoc()"}
]
}
}
}
Whereas an object would look like:
var obj = {
menu1 : {
"id": "file",
"value": "File",
"popup": {
"menuitem": [
{"value": "New", "onclick": "CreateNewDoc()"},
{"value": "Open", "onclick": "OpenDoc()"},
{"value": "Close", "onclick": "CloseDoc()"}
]
}
},
menu2 : {
"id": "file2",
"value": "File2",
"popup": {
"menuitem": [
{"value": "New", "onclick": "CreateNewDoc()"},
{"value": "Open", "onclick": "OpenDoc()"},
{"value": "Close", "onclick": "CloseDoc()"}
]
}
}
};
So techincally they are two different JavaScript objects, but thats irrelevant to the question.
To answer your question christophe.humbert some object key/values have to have quotes on them if they already exist as a predefined JavaScript method/property etc, such as "for" and "class" for example.
This is the same for keys that have "-" ("background-color" for example)or "_" in them.
But for any other case they are optional, but obviously strings much be in quotes.
(Incase you did not know, In the example you gave "location" would be the key and 'top' would be the value )
© 2013 jQuery Foundation
Sponsored by and others.