lang
HTML DOM lang 属性
定义和用法
lang 属性设置或返回元素的语言。
语法
HTMLElementObject.lang=language-code
浏览器支持
所有主要浏览器都支持 lang 属性
实例
返回元素的语言:
<html>
<body id="myid" lang="en-us">
<script>
var x=document.getElementsByTagName(‘body‘)[0];
document.write("Body language: " + x.lang);
document.write("<br>");
document.write("An alternate way: ");
document.write(document.getElementById(‘myid‘).lang);
</script>
</body>
</html>
<body id="myid" lang="en-us">
<script>
var x=document.getElementsByTagName(‘body‘)[0];
document.write("Body language: " + x.lang);
document.write("<br>");
document.write("An alternate way: ");
document.write(document.getElementById(‘myid‘).lang);
</script>
</body>
</html>
输出结果:
Body language: en-us
An alternate way: en-us
An alternate way: en-us