Check if An Element is Hidden or Visible using jQuery JavaScript?

JavaScript


        function checkifvisblejs(){
            if(document.getElementById('logoimg').style.display == 'none'){
                document.getElementById('checkifvisblejsdiv').innerHTML = "Image logo is Hidden!";
            }else{
                document.getElementById('checkifvisblejsdiv').innerHTML = "Image logo is Visible!";
            }
        }
    

jQuery


        $("#checkifvisblejq").on("click",function(){
            var isVisible = false;
            //Method 1
            isVisible = $("#logoimg:visible").length;
            //Method 2
            isVisible = $("#logoimg").is(":hidden");
            //Method 3
            isVisible = !$("#logoimg").is(":visible");
            //Method 4
            isVisible = ($("#logoimg").css("display")=='none');

            if(isVisible){
                $("#checkifvisblejqdiv").html("Image logo is Hidden!");
            }else{
                $("#checkifvisblejqdiv").html("Image logo is Visible!");
            }
        });