开发者

Why does jslint shout at me?

开发者 https://www.devze.com 2023-03-22 21:53 出处:网络
My code is the following (also availa开发者_高级运维ble at jsfiddle): $button = $(\'<button />\', {

My code is the following (also availa开发者_高级运维ble at jsfiddle):

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

The jslint error message is:

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


Class is a reserved word for Javascript 2.0, thus you should not use it as a key in an object without putting it between quotes to mark it as a string.

0

精彩评论

暂无评论...
验证码 换一张
取 消