Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

addClass - can add multiple classes on same div?

Tags:

jquery

jQuery add multiple class

This is my current code, I know its wrong code

$('.page-address-edit').addClass('test1').addClass('test2'); 
like image 913
Hunter Avatar asked Jun 13 '12 07:06

Hunter


People also ask

Can you add multiple classes to a div?

Absolutely, divs can have more than one class and with some Bootstrap components you'll often need to have multiple classes for them to function as you want them to. Applying multiple classes of course is possible outside of bootstrap as well. All you have to do is separate each class with a space.

Can we add more than one CSS classes to the selected elements using the addClass () method?

The addClass() method adds one or more class names to the selected elements. This method does not remove existing class attributes, it only adds one or more class names to the class attribute. Tip: To add more than one class, separate the class names with spaces.

Can you add multiple classes to an element?

HTML elements can be assigned multiple classes by listing the classes in the class attribute, with a blank space to separate them.

Can we use two classes in same element?

Multiple classes can be applied to a single element in HTML and they can be styled using CSS.


1 Answers

$('.page-address-edit').addClass('test1 test2 test3'); 

Ref- jQuery

like image 167
ShibinRagh Avatar answered Sep 21 '22 15:09

ShibinRagh