Reputation: 35
I need to include two classes as mentioned below..But it is not working.Could anyone look into the issue and suggest me a solution.
$('.list_Person .Skills').addClass("active");
Thanks in advance.
Upvotes: 0
Views: 196
Reputation: 67207
Use a comma
to achieve what you want. It is called as multiple selector
.
Try,
$('.list_Person,.Skills').addClass("active");
If you want to add more than one class to a particular selection,just insert a space between the set of classes and then add it,like below:
$('.class').addClass('class1 class2 class3');
Upvotes: 3
Reputation: 5490
if you want to add two new class to a selector
$('.class1').addClass("class2 class3");
and if you want to add two class in selector
both class should be there
$('.class1').filter('.class2').addClass('class3');
either one class
$('.class1,.class2').addClass('class3');
Upvotes: 0
Reputation: 264
you can separate multiple classes with the space:
$('.list_Person .Skills').addClass("active secondClass thirdClass");
Upvotes: 0
Reputation: 82231
For adding two classes
$('.list_Person .Skills').addClass("active active2");
For adding In two classes
$('.list_Person,.Skills').addClass("active");
Upvotes: 0
Reputation: 13379
I am assuming you are just jquery begginer and want to select .active
elements
$('.active').addClass("list_Person Skills");
Upvotes: 0
Reputation: 386
Try this
$('.list_Person').addClass("active").addClass("Skills");
Upvotes: 0