18 June 2017

Access html elements in the same table row using jQuery

   <table>  
     <tr>  
       <td>Mary</td>  
       <td><div id="parentTimer"></div></td>  
       <td id="td">  
         <button id="btnStart" type="button" onclick="handleStart(event, this);">Start</button>  
         <input id="inputValue" value="Test" />  
       </td>  
     </tr>  
   </table>  
   <script>  
     function handleStart(event, sender)  
     {  
       var $row = $(sender).parents('tr');  
       var desc = $row.find('#inputValue').val();  
       var div = $row.find('#parentTimer');  
       div.html('started');  
       alert(desc);  
     }  
   </script>  

No comments:

Post a Comment