- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How can I tell if table row is in view using jQuery?
To check if table row exists or not, use the is() method, with the :visible selector −
if($(".row").is(":visible")) { alert("Visible!"); }
You can try to run the following code to learn how to chck if a row exists or not. It even notifies when a new row is created −
Example
<!DOCTYPE html> <html> <head> <title>jQuery - Add Table Rows</title> <style> table{ width: 100%; margin: 25px 0; border-collapse: collapse; } table, th, td{ border: 1px solid #6C220B; } table th, table td{ padding: 8px; text-align: left; } </style> <script src="https://code.jquery.com/jquery-3.2.1.min.js"></script> <script> $(document).ready(function(){ $(".row").click(function(){ if($(".row").is(":visible")) { alert("Exists: A new row will create now."); } var name = $("#name").val(); var subject = $("#subject").val(); var markup = "<tr><td><input type='checkbox' name='record'></td><td>" + name + "</td><td>" + subject + "</td></tr>"; $("table tbody").append(markup); }); }); </script> </head> <body> <form> <input type="text" id="name" placeholder="Enter Name"> <input type="text" id="subject" placeholder="Enter Subject"> <input type="button" class="row" value="Click to Add Row"> </form> <table> <thead> <tr> <th>Choose</th> <th>Name</th> <th>Subject</th> </tr> </thead> <tbody> <tr> <td><input type="checkbox" name="result"></td> <td>Amit</td> <td>Java</td> </tr> </tbody> </table> </body> </html>
- Related Articles
- How to add table row in jQuery?
- How to add a new row in a table using jQuery?
- How to delete a row from a table using jQuery?
- How can I tell when a MySQL table was last updated?
- How can I tell if a string repeats itself in Python?
- How to select the last row of a table using jQuery?
- Does deleting row from view delete row from base table in MySQL?
- How to insert new row into table at a certain index using jQuery?
- How to Add Edit and Delete Table Row in jQuery?
- How can I view cascades in MySQL?
- How can I remove everything inside of a using jQuery?
- How can I customize value, instead of NULL, of a row by using MySQL IF() function?
- How can I change the value of an instance of a row in MySQL table?
- How can I update a table using prepare statements?
- How can I show and hide an HTML element using jQuery?

Advertisements