Reputation: 2973
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?
Upvotes: 2
Views: 13019
Reputation: 1261
Getting the class after clicking on btn-group
$('.btn-group').on('click', function(){
$(this).addClass('dropdown open');
})
Upvotes: 3
Reputation: 8726
try this
$('.btn-group').addClass('dropdown');
$('.btn-group').addClass('open');
Upvotes: 2