How to check if an element is hidden using jQuery

  1336 views   2 years ago jQuery

Use the jQuery :hidden Selector

The jQuery :hidden selector can be used to test whether an element is hidden or not on a page.

You can also use this selector to test the elements whose  width  and  height  are set to 0 as well as the form elements with the attribute type="hidden". Let's see how it works:

<!DOCTYPE html>
<html lang="en">
<meta charset="utf-8">
<title>jQuery Test If an Element is Hidden</title>
<script src=""></script>
            // show hide paragraph on button click
            $("p").toggle("slow", function(){
                // check paragraph once toggle effect is completed
                    alert("The paragraph  is hidden.");
                } else{
                    alert("The paragraph  is visible.");
    <button type="button">Toggle Paragraph Display</button>
    <p>Lorem ipsum dolor sit amet adipi elit...</p>


Author : Harsukh Makwana
Harsukh Makwana

Hi, My name is Harsukh Makwana. i have been work with many programming language like php, python, javascript, node, react, anguler, etc.. since last 5 year. if you have any issue or want me hire then contact me on [email protected]