mardi 16 juin 2015

with an input checkbox inside a table row, can i add click event to row and still be able to click input

I have a table:

<table>
  <tr>
    <td>Something</td>
    <td>Something Else</td>
    <td><input type='checkbox' value='clickme' id='yes'></td>
  </tr>

For the user, if they click the row, they get more data about the row, and if they click the checkbox, they are presented with some other options. how can i listen for each event in jquery. My problem is that the click for checkbox obviously fires off the event for the row click

$('tr').click(function(){
     alert('you clicked the row');
});
$('#yes').change(function(){
      alert('you clicked the checkbox');
});




Aucun commentaire:

Enregistrer un commentaire