Javascript DOM CSS Style display Property get

Introduction

Return the display type of a <p> element:

alert(document.getElementById("myP").style.display);

View in separate window

<!DOCTYPE html>
<html>
<body>

<p id="myP" style="display:none;">This is a p element.</p>

<button type="button" onclick="myFunction()">Return the display type of p</button>

<p id="demo"></p>
<script>
function myFunction() {//ww w.  ja va  2s  . c om
  document.getElementById("demo").innerHTML = document.getElementById("myP").style.display;
}
</script>

</body>
</html>



PreviousNext

Related