lang 属性可设置或返回元素的预言代码。
bodyObject.lang=language-code
下面的例子将展示获取 <body> 元素的语言代码的两种方法:
<html> <body id="myid" lang="en-us"> <script type="text/javascript">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