Finding if element is visible (JavaScript )

前端 未结 4 1511
悲哀的现实
悲哀的现实 2021-02-05 19:44

I have a javascript function that tries to determine whether a div is visible and does various processes with that variable. I am successfully able to swap an elements visibilit

4条回答
  •  天涯浪人
    2021-02-05 20:25

    Try like this:

    $(function () {
        // Handler for .ready() called.
        if ($("#mydivID").is(":visible")) {
            alert('Element is visible');
        }
    });
    

    FIDDLE

    Please make sure to include the jQuery file inside the head tag, as follows

    
      
    
    

提交回复
热议问题