Javascript DOM CSS Style letterSpacing Property get

Introduction

Return the letter spacing of a <p> element:

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

View in separate window

<!DOCTYPE html>
<html>
<body>

<p id="myP" style="letter-spacing:10px;">This is an example paragraph.</p>

<button type="button" onclick="myFunction()">Return letter spacing of p</button>

<p id="demo"></p>
<script>
function myFunction() {/*from  w w w  . ja  va 2 s .  co m*/
  document.getElementById("demo").innerHTML = document.getElementById("myP").style.letterSpacing;
}
</script>

</body>
</html>



PreviousNext

Related