1

here is the code

<table class="table">
  <tbody>
    <tr>
      <td></td>
      <td>Destination</td>
      <td>Service Charges</td>
      <td>Time Frame</td>
    </tr>
    <tr class="uk">
      <td><input checked="checked" type="radio" name="shiping-method" id="shipping-method" value="1"></td>
      <td>uk</td>
      <td>free</td>
      <td>2-4 working days</td>
    </tr>
    <tr class="uk">
      <td><input type="radio" name="shiping-method" id="shipping-method" value="3"></td>
      <td>uk</td>
      <td>6.00</td>
      <td>next working day</td>
    </tr>
  </tbody>
</table>

these values are not accessible on the main page I am trying to use the following code

$('input[type="radio"]').on('click',function(){
   var value = $(this).val();
   alert($(this).val());
});
Serving Quarantine period
  • 66,345
  • 10
  • 43
  • 85
samar
  • 160
  • 12

1 Answers1

0

You can use event delegation in below way:-

$('.table').on('click','input[type="radio"]',function(){ 
   var value = $(this).val(); 
   alert($(this).val()); 
});

Working example:-

$('.table').on('click','input[type="radio"]',function(){
      var value = $(this).val();
     alert($(this).val());

});

$('.clickMe').click(function(){
$("<tr class='uk'><td><input checked='checked' type='radio' name='shiping-method' id='shipping-method' value='1'></td><td>uk</td><td>free</td><td>2-4 working days</td></tr><tr class='uk'><td><input type='radio' name='shiping-method' id='shipping-method' value='3'></td><td>uk</td><td>6.00</td><td>next working day</td></tr>").insertAfter($('.table tbody tr'));

});
table {
    width: 100%;
}

tr {
    height: 50px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<table class="table">
  <tbody>
    <tr>
      <td>Check</td>
      <td>Destination</td>
      <td>Service Charges</td>
      <td>Time Frame</td>
    </tr>
  </tbody>
</table>
<br>
<input type="button" class="clickMe" value="ClickMe!">
Serving Quarantine period
  • 66,345
  • 10
  • 43
  • 85