Reputation: 23
I am trying to remove colspan
class but it is removing only create
class.
<td class="create colspan">
</td>
if ($(this).prev().hasClass('colspan') || $(this).next().hasClass('colspan')) {
alert('yes');
} else {
$(this).removeClass();
$(this).removeClass('.colspan')
}
Upvotes: 2
Views: 203
Reputation: 82241
You dont need to pass class selector .
in removeClass()
.so use:
$(this).removeClass('colspan')
to remove both classes colspan
and create
,use:
$(this).removeClass('colspan create')
Upvotes: 3
Reputation: 38102
You don't need .
here, you just need to provide the name of your class to remove when using .removeClass():
$(this).removeClass('colspan')
Actually, when you use $(this).removeClass()
, it's already remove all classes that is inside $(this)
element including colspan
and create
.
Besides that, if you want to remove multiple classes like colspan
and create
which is your case, then you can separate the class name by space:
$(this).removeClass('colspan create')
Upvotes: 5