Javascript DOM CSS Style fontVariant Property get

Introduction

Return the font variant of a <p> element:

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

View in separate window

<!DOCTYPE html>
<html>
<body>

<p id="myP" style="font-variant:small-caps">This is a paragraph.</p>

<button type="button" onclick="myFunction()">Return font variant</button>

<p id="demo"></p>

<script>
function myFunction() {//from w  ww.  j  av a  2s  .  c o m
  document.getElementById("demo").innerHTML = document.getElementById("myP").style.fontVariant;
}
</script>

</body>
</html>



PreviousNext

Related