Return the text direction of a <p> element: - Javascript CSS Style Property

Javascript examples for CSS Style Property:direction

Description

Return the text direction of a <p> element:

Demo Code

ResultView the demo 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>

<script>
function myFunction() {/*from ww w  .  j  a  v  a 2s.c  o m*/
    console.log(document.getElementById("myP").style.direction);
}
</script>

</body>
</html>

Related Tutorials