What causes to event

Hi, i am just wondering. ,why is that onclick will not trigger or fire out in my table,example when my data loaded to the table, when i click a table row it will not trigger yet the onclick but when i double click on it.Now the event will function properly.

please enlighten my mind.


<table>
   <tr>
   <tr class="b" onclick="myFunction('03');">
      <td><span>1</span></td>
       <td><span>pencil</span></td>
   </tr>

   <tr   class="b" onclick="myFunction('05');">
      <td><span>2</span></td>
       <td><span>ruler</span></td>
   </tr>

   <tr   class="b" onclick="myFunction('06');">
      <td><span>3</span></td>
       <td><span>table</span></td>
   </tr>
</table


request data via ajax.


 $.ajax{(
   .......,
   ........,
   success: function(dtl){
     //load table data here.
   }

});


here is my code in click


$(function(){
   $('tr.b').onclick(function(){
     alert('I am click');
 });
});



Which of those onclicks do you expect to work - the ones in the script or the ones in the HTML - whichever is set last is overwriting the other one - one reason why you shouldn’t jumble JavaScript with HTML.

Hi felgal,

This one


$(function(){
   $('tr.b').onclick(function(){
     alert('I am click');
 });
});