Thursday, 5 June 2014

Count Number of columns in a table using javascript or jquery


//HTML

<table id="table1">
<tr>
  <td></td>
  <td></td>
  <td></td>
  <td></td>
</tr>
<tr>
</table>
cells
<script>
alert(document.getElementById('table1').rows[0].cells.length)
</script>

//Jquery

 <script type="text/javascript">
       $(document).ready(function () {
              alert($(Table).find('tr')[0].cells.length);
         

       });  
   </script>

No comments:

Post a Comment

How to highlight selected text in notepad++

  –> To highlight a block of code in Notepad++, please do the following steps step-1  :- Select the required text. step-2  :- Right click...