javascript - Expected identifier, string or number - Stack Overflow

I have an object like;var defaults = {id: 'ActionSlider',element: '',closeBtnWidth:

I have an object like;

var defaults = {
        id: 'ActionSlider',
        element: '',
        closeBtnWidth: 55,
        panelWidth: 320,
        class: '',
        css: {},
        create: function() {},
    },

and when i run my page in IE8 standards its giving me the following error;

SCRIPT1028: Expected identifier, string or number

and points to the line : class:' ',

can anyone please tell me why i cant use this for IE? is it a reserved word or something?

I have an object like;

var defaults = {
        id: 'ActionSlider',
        element: '',
        closeBtnWidth: 55,
        panelWidth: 320,
        class: '',
        css: {},
        create: function() {},
    },

and when i run my page in IE8 standards its giving me the following error;

SCRIPT1028: Expected identifier, string or number

and points to the line : class:' ',

can anyone please tell me why i cant use this for IE? is it a reserved word or something?

Share Improve this question edited Feb 5, 2013 at 7:48 KARASZI István 31.5k9 gold badges106 silver badges131 bronze badges asked Feb 5, 2013 at 7:46 user2042215user2042215 452 silver badges4 bronze badges
Add a ment  | 

4 Answers 4

Reset to default 6

You need to add quotes round the class which is a reserved word. Please also note, that you should remove the last ma:

var defaults = {
        id: 'ActionSlider',
        element: '',
        closeBtnWidth: 55,
        panelWidth: 320,
        "class": '',
        css: {},
        create: function() {}
    }

Yep, class is a reserved word. MDN

class is reserved words in javascript

Usually class refers to the class attribute of any object like <div >, <input > etc. which shows displays class as <div class="someclass">

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744791311a4593931.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信