Element dir Property - Get the text direction of a <p> element: - Javascript DOM

Javascript examples for DOM:Element dir

Description

Element dir Property - Get the text direction of a <p> element:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<p id="myP" dir="rtl">Click the button to display my text direction.</p>

<button onclick="myFunction()">Test</button>

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

<script>
function myFunction() {/*from   w  w  w.  j a  v  a 2  s  .  c o m*/
    var x = document.getElementById("myP").dir;
    document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>

Related Tutorials