SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Thread: TD alert

  1. #1
    SitePoint Wizard
    Join Date
    May 2012
    Posts
    1,087
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Post TD alert

    Hi can you help me on this please, I am trying to alert when i click the table row.

    but it will only alert in the first row, even i clicked in the last row.

    Code:
      $(function(){
          $(this).click(function(e){
    
           if($(e.target).is('tr.mytableClass,tr#mytableID span')){
                 var esp = $('tr.mytableClass,tr#mytableID ').find('td').eq(1).text();
                 alert(esp);
           }
    
    
    
        });
    });
    HTML Code:
      <table  class="mytable">
               <tr>
                     <td><span> 0001<span></td>
                      <td><span> Daniela<span></td>
                       <td><span> Shake<span></td>
                </tr>
    
                 <tr>
                     <td><span> 0002<span></td>
                      <td><span> Jenny<span></td>
                       <td><span>Max<span></td>
                </tr>
    
                 <tr>
                     <td><span> 0002<span></td>
                      <td><span> Mecy<span></td>
                       <td><span>Vilz<span></td>
                </tr>
    
    
     </table>

  2. #2
    SitePoint Wizard
    Join Date
    May 2012
    Posts
    1,087
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    OOps looks like i fixed my problem.. great!.

    thanks to .children()


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
  •