I need to add a class named “active” to my parent class “item” using jQuery.
It seems simple but my following code is not adding the new class to the parent.
Note: I am doing this inside form.phtml file inside Magento2.
The code here prints the alert but not adding the class.
jQuery('.item-info').click(function(e){
$(this).parent().addClass('active');
// alert('test');
});
This is my html:
<tbody class="cart item">
<tr class="item-info">
Expected html:
<tbody class="cart item active">
<tr class="item-info">