What is jQuery?


  • jQuery is a small, light-weight and fast JavaScript library. It’s cross-platform and supports different types of browsers. It’s also referred as Write less do more? Because it takes a lot of common tasks that needs many lines of JavaScript code to accomplish, and binds them into methods which will be called with a single line of code whenever needed.
  • It’s also very useful to simplify a lot of the complicated things from JavaScript, like AJAX calls and DOM manipulation.

How to Count Number of Rows in a Table Using jQuery

Answer: Use the length Property

  • You can simply use the length property to count or find the amount of rows in an HTML table using jQuery. This property is used to get the amount of elements in any jQuery object.
  • Let’s try the following example to know how it actually works:


<!DOCTYPE html>
<html lang="en">
<meta charset="utf-8">
<title>jquery Get Number of Rows in a Table</title>
<script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
Var rowcount = $("#mytable tr").length;
Alert(rowcount); // Outputs: 4
<table id="mytable" border="1" width="140">
<button type="button">Get Number of Rows</button>


Categorized in: