Get dir from element in JavaScript

Description

The following code shows how to get dir from element.

Example


<!--from   ww w .  j  av  a2  s  .co  m-->
<!DOCTYPE HTML>
<html>
<body>
<p id="textblock" dir="ltr" lang="en-US">
<span id="banana">banana</span>
<span id="apple">apples</span>
<span="orange">oranges</span>
This is a test.
</p>
<script>
var results = document.getElementById("results");
var elem = document.getElementById("textblock");
document.writeln("dir: " + elem.dir);

</script>
</body>
</html>

Click to view the demo

The code above generates the following result.

Get dir from element in JavaScript
Home »
  Javascript Tutorial »
    DOM »
      Get
Javascript Tutorial Get
Access data attributes in HTML element in J...
Behave differently for different element id...
Call getElementById for duplicate id in Jav...
Clone a HTML element and output its inner h...
Clone a node in JavaScript
Compare node type to a numeric value in Jav...
Compare the value of innerText and innerHTM...
Convert NodeList to an Array in JavaScript
Convert a NodeList to an array in Internet ...
Create a HTML element in JavaScript
Create new HTML element and set its inner t...
Deal with null sibling value in JavaScript
Deal with the single child with lastChild i...
Get all attributes for a HTML element in Ja...
Get attribute from a HTML element in JavaSc...
Get child node by index in JavaScript
Get dir from element in JavaScript
Get disabled from element in JavaScript
Get element array by class name in JavaScri...
Get element array length returned by getEle...
Get element by id in JavaScript
Get elements by tag name with getElementsBy...
Get hidden from element in JavaScript
Get id from element in JavaScript
Get lang from element in JavaScript
Get tag name from element in JavaScript
Get tags by name using getElementsByName fu...
Get the first child for an element in JavaS...
Get the inner html for a HTML element in Ja...
Get the inner text for a HTML element in Ja...
Get the nodeName and nodeValue in JavaScrip...
Get the outer html for a HTML element in Ja...
Get the parent node in JavaScript
Get the previous sibling and next sibling i...
Get the reference to entire document in Jav...
List attribute for a HTML element by name a...
Loop through the array returned by getEleme...
Reference a button directly using its id in...
Show nodes are stored in a NodeList in Java...
Use length to get the last child in JavaScr...