mardi 15 mai 2018

prop checked does not work - special case

Why when you click on the first button does not ckecked? why when referring to the same ckeckbox one script does not work while the other does it correctly?

$('.button1').click(function(event){
  //console.log("click1");
  $('#table1 .checkbox1').prop('checked',true);
});
$('.button2').click(function(event){
  //console.log("click2");
  $('.checkbox1').prop('checked',true);
});
<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>

<table id="table1">
  <input type="checkbox" class="checkbox1" />
  <input type="button" class="button1"  value="Checked1" />
  <input type="button" class="button2"  value="Checked2" />
</table>



Aucun commentaire:

Enregistrer un commentaire