Expected id, string or number
I have an object like this:
var defaults = {
id: 'ActionSlider',
element: '',
closeBtnWidth: 55,
panelWidth: 320,
class: '',
css: {},
create: function() {},
},
and when I run my page in IE8 standards it gives me the following error:
SCRIPT1028: expected ID, string or number
and points to the line: class: '',
Can someone tell me why I can't use this for IE? is it a reserved word or something else?
You need to add quotation marks around class
which is a reserved word. Also note that you must remove the last comma:
var defaults = {
id: 'ActionSlider',
element: '',
closeBtnWidth: 55,
panelWidth: 320,
"class": '',
css: {},
create: function() {}
}
Yep, class
is a reserved word. MDN
class
reserved words in javascript
Typically a class refers to a class attribute of any object such as <div >
, <input >
etc., which shows the display class as<div class="someclass">