为什么jslint会对我大喊大叫?

时间:2011-07-26 20:32:18

标签: jslint

我的代码如下(也可在jsfiddle处获得):

$button = $('<button />', {
    text: 'my button',
    class: 'button'
});

jslint错误消息是:

Problem at line 3 character 5: Expected an identifier and instead saw 'class' (a reserved word).
class: 'button'

1 个答案:

答案 0 :(得分:8)

Class is a reserved word for Javascript 2.0,因此您不应将其用作对象中的键而不将其放在引号之间以将其标记为字符串。