Take the 2-minute tour ×

My code is the following (also available 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'
share|improve this question
I think it's complaining that class is a reserved keyword, so to use it you might need quotation marks to distinguish it from the keyword. But not sure... –  Adam M-W Jul 26 '11 at 20:36

1 Answer 1

up vote 6 down vote accepted

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.

share|improve this answer
And class: "myString" to 'class': 'myString' works. fiddle –  ruffin May 28 '13 at 21:08

Your Answer


