Is there a way to dynamically add and remove CSS classes to the parent of a specific element on a web page using a link button? Here is the code snippet:
<div class="prod-box shadow">
<div class="prod-details">
</div>
</div>
<div class="prod-compare">
<div class="compare">
<a href="javascript:void();" class="add-to-compare" data-id="123">Add to Compare</a>
</div>
</div>
I am attempting to change the class "prod-box shadow" to "prod-box shadow-blue". The jQuery code I tried was:
$(this).parent('div .prod-box').removeClass('shadow');
$(this).parent('div .prod-box').addClass('shadow-blue');