Ctrl_Alt_Defeat Ctrl_Alt_Defeat - 1 month ago 17
jQuery Question

remove keyword from class name

I have the following markup - what i need to achieve is remove the 'active' word from the day class (on the line in bold in the markup)

<div class="datepicker-days" style="display: block;">
<table class="table-condensed">
<thead>
<tr>
<th colspan="7" class="datepicker-title" style="display: none;"></th>
</tr>
<tr><th class="prev" style="visibility: visible;">«</th><th colspan="5" class="datepicker-switch">November 2016</th><th class="next" style="visibility: hidden;">»</th></tr>
<tr><th class="dow">Su</th><th class="dow">Mo</th><th class="dow">Tu</th><th class="dow">We</th><th class="dow">Th</th><th class="dow">Fr</th><th class="dow">Sa</th></tr>
</thead>
<tbody>
<tr>
<td class="day old">30</td>
<td class="day old">31</td>
**<td class="day active today">1</td>**
<td class="day disabled">2</td>
<td class="day disabled">3</td>
</tr>
</tbody>
<tfoot><tr><th colspan="7" class="today" style="display: none;">Today</th></tr><tr><th colspan="7" class="clear" style="display: none;">Clear</th></tr></tfoot>
</table>
</div>


I tried the following jQuery but it doesnt seem to be working

$('.day').css('active', '');

Answer

Did you hear about .removeClass() method in jquery.

Remove a single class, multiple classes, or all classes from each element in the set of matched elements.

$('.day.active').removeClass('active');

https://api.jquery.com/removeclass/