Javascript Style How to - Get element visibility








Question

We would like to know how to get element visibility.

Answer


<!DOCTYPE html>
<html>
<head>
<script type='text/javascript'>
window.onload=function(){<!--from   ww  w .  j  a v  a  2  s .  c  o m-->
console.log( document.getElementById('test').style.visibility );
}
</script>
</head>
<body>
  <div id="test" style="visibility: visible">some text here</div>
</body>
</html>

The code above is rendered as follows: