Javascript DOM CSS Style wordSpacing Property get

Introduction

Return the word spacing of a <p> element:

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

View in separate window

<!DOCTYPE html>
<html>
<body>

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

<button type="button" onclick="myFunction()">Return word spacing of p</button>
<p id="demo"></p>
<script>
function myFunction() {//from  w  ww . j a v  a  2  s  . c  o m
  document.getElementById("demo").innerHTML = document.getElementById("myP").style.wordSpacing;
}
</script>

</body>
</html>



PreviousNext

Related