JSFiddle - React, Tailwind, and code Playground

by mayur rahul

HTML

<tr class="itemSize">
        <td>
          <span class="danger">*</span><label class="itemSize">Product Sizes:</label>
        </td>
        <td>
          <label for="extra_small">XS</label><input type="checkbox" name="extra_small" id="extra_small" value="XS">
          <label for="small">S</label><input type="checkbox" name="small" id="small" value="S">
          <label for="medium">M</label><input type="checkbox" name="medium" id="medium" value="M">
          <label for="large">L</label><input type="checkbox" name="large" id="large" value="L">
         </td>
      </tr>

JavaScript

$('#extra_small,#small,#medium, #large, #extra_large').on('change',function(){
    var $sizeTr = $('.itemSize');
    if(this.checked){
      console.log("checked");
      var size = $(this).attr("id");
      var html = 
      '<tr class="'+size+'_quantity">'+
       '<td>'+
          '<span class="danger">*</span><label for="itemQuantity">'+size+' Stock Quantity:</label>'+
        '</td>'+
        '<td>'+
          '<input type="number" min="1" name="itemQuantity" placeholder="Enter Product Quantity" value=""/>'+
        '</td>'+
      '</tr>';
      //$('.itemSize').after(html);
      $(html).insertAfter($sizeTr);
      //console.log( $(html));
    }else{
      $('tr.'+size+'_quantity').hide();
    }
  });