Javascript DOM CSS Style direction Property get

Introduction

Return the text direction of a <p> element:

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

View in separate window

<!DOCTYPE html>
<html>
<body>

<p id="myP" style="direction:rtl;">This is an example paragraph.</p>

<button type="button" onclick="myFunction()">Return text direction</button>

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

</body>
</html>



PreviousNext

Related