Finding if element is visible (JavaScript )

前端 未结 4 1513
悲哀的现实
悲哀的现实 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:12

    Display is not an attribute, it's a CSS property inside the style attribute.

    You may be looking for

    var myvar = document.getElementById("mydivID").style.display;
    

    or

    var myvar = $("#mydivID").css('display');
    

提交回复
热议问题