Skip to content
Related Articles

Related Articles

How to check if an element is hidden in jQuery?

View Discussion
Improve Article
Save Article
  • Last Updated : 28 Mar, 2019

To check if an element is hidden or not, jQuery :hidden selector can be used. .toggle() function is used to toggle the visibility of an element.




<!DOCTYPE html>
<html lang="en">
    <meta charset="utf-8">
        Jquery Hidden element Checking
        h1 {
            color: green;
        td {
            border: 1px solid black;
    <script src=
    <script type="text/javascript">
        $(document).ready(function() {
            $("button").click(function() {
                $("table").toggle("slow", function() {
                    if ($("table").is(":hidden")) {
                        alert(" Hidden Element.");
                    } else {
                        alert("Element Visible.");
        <h1>Geeks for Geeks</h1>
        <button type="button">
        <table style="width:60%">
                <th>Language Index</th>
                <th>Language Name</th>

Before Clicking:

After Clicking:

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!