Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add two classes to an existing class with jquery?

Tags:

jquery

I have this element:

<div class="btn-group"></div>

And I have an click event in jquery and I have selected above div and now after selecting the element I want to add two classes named dropdown and open to its btn-group class.

It means I want to have this:

<div class="btn-group dropdown open"></div>

If the element already contains the btn-group class.

How can I do that?

like image 705
Hamid Reza Avatar asked Jan 21 '26 18:01

Hamid Reza


1 Answers

Try

$('.btn-group').addClass('dropdown open')
like image 74
Arun P Johny Avatar answered Jan 25 '26 03:01

Arun P Johny