Friday 7 May 2021

JQUERY21

 

<html>

<head>

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>

<script>

$(document).ready(function() {

$.fn.rowCount = function() {

return $('tr', $(this).find('tbody')).length;

};

$.fn.columnCount = function() {

return $('th', $(this).find('tbody')).length;

};

var rowctr = $('#table1').rowCount();

var colctr = $('#table1').columnCount();

$('#parray').text(rowctr);

$('#iarray').text(colctr);

});

</script>

</head>

<body>

<p>No of Rows:<span id="parray"></span></p>

<p>No of Columns:<span id="iarray"></span></p>

<table id="table1">

 

<tr>

<th>Sr.No</th>

<th>Name</th>

</tr>

<tr>

<td>1</td>

<td>AAA</td>

</tr>

<tr>

<td>2</td>

<td>BBB</td>

</tr>

<tr>

<td>3</td>

<td>CCC</td>

</tr>

<tr>

<td>4 </td>

<td>DDD</td>

</tr>

</table>

</body>

</html>