How to check using jQuery if an element is display none or block

← PrevNext →

You can use the .css() function in jQuery to check if an element or a group of elements have display 'none' or 'block' property.

Here's an example.

<!DOCTYPE html>
    <script src=""></script>
      p { 
        display: inline-block;
        padding: 10px;
        width: auto;
      p:nth-child(2) { display: none; }

    <p> alpha </p>
    <p> bravo </p>      <!--this element is display: none-->
    <p> charlie </p>    
    <p> delta </p>
    <p> echo </p>

    <input type='button' value='Click it' id="bt">

  $('#bt').click(function () {
  let check_if_hidden = () => {
    $('p').each(function () {      // check if elment is display none.
      if ($(this).css('display') == 'none')  {
        $(this).fadeIn('slow').css('display', 'inline-block');
Try it

Remember, when an element's display property is set as "none", the element will not take up any space.

Also read... How to change CSS display to none or block using jQuery.

Happy coding. 🙂

← PreviousNext →