Javascript DOM CSS Style fontStyle Property get

Introduction

Return the font style of a <p> element:

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

View in separate window

<!DOCTYPE html>
<html>
<body>

<p id="myP" style="font-style:italic;">This is a paragraph.</p>

<button type="button" onclick="myFunction()">Return font style</button>
<p id="demo"></p>
<script>
function myFunction() {/*from www  . j  a v a 2  s  .  co  m*/
  document.getElementById("demo").innerHTML = document.getElementById("myP").style.fontStyle;
}
</script>

</body>
</html>



PreviousNext

Related