Reputation: 16651
I want to add multiple classes to an html element
I know the following code is possible.
$("ul#List").find("li.template")
.removeClass("template")
.addClass("entry")
But i want to know if the following code is also possible.?
$("ul#List").find("li.template")
.removeClass("template")
.addClass("entry1")
.addClass("entry2")
Upvotes: 0
Views: 905
Reputation: 17350
$("ul#List").find("li.template")
.removeClass("template")
.addClass("entry1 entry2")
Edit: Take a look http://jsfiddle.net/nHs9W/
Both of the below snippets work
.addClass("entry1 entry2");
.addClass("entry1").addClass("entry2");
Upvotes: 3
Reputation: 101473
-1 for not reading the manual!
But anyway, from that page,
.addClass( className )
className: One or more class names to be added to the class attribute of each matched element.
The most important part being one or more
Upvotes: 0
Reputation: 6742
you can add multiple classes separated by a space:
.addClass("entry1 entry2")
Upvotes: 2