I Have two Select Box with the same class.I am trying to add a class on the change of select option.
HTML:
<select class="selectProduct" name="product_id[]">
<option value="T-shirt">T-Shirt</option>
</select>
<input type="text" name="sku[]" placeholder="Code" id ="sku" class="code" />
<input type="text" name="qty[]" placeholder="Qty" id ="qty" class="qty" />
<select class="selectProduct" name="product_id[]" style="width:400px;">
<option value="shirt">Shirt</option>
</select>
<input type="text" name="sku[]" placeholder="Code" id ="sku" class="code" />
<input type="text" name="qty[]" placeholder="Qty" id ="qty" class="qty" />
jQuery:
$(document).on('change', '.selectProduct', function(e) {
var idSize = $(this).val();
$(this).find(".code").addClass(idSize);
});