Javascript examples for DOM:Element lang
The lang property sets or gets the lang attribute of an element, which controls the language code of the element's content.
For example, "en" for English, "es" for Spanish, "fr" for France and so on.
Set the lang property with the following Values
Value | Description |
---|---|
language_code | Sets the language code for the element's content. |
A String, representing the language of the element's text
The following code shows how to Get the language code of a <p> element:
<!DOCTYPE html> <html> <body> <p id="myP" lang="en">Click the button.</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").lang; document.getElementById("demo").innerHTML = x; } </script> </body> </html>