SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Wizard
    Join Date
    May 2012
    Posts
    1,096
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Post 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.
    HTML Code:
    <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.
    Code:
     $.ajax{(
       .......,
       ........,
       success: function(dtl){
         //load table data here.
       }  
       
    });
    here is my code in click
    Code:
    $(function(){
       $('tr.b').onclick(function(){
         alert('I am click');
     });
    });

  2. #2
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,789
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    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.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  3. #3
    SitePoint Wizard
    Join Date
    May 2012
    Posts
    1,096
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Hi felgal,

    This one

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


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •