当前位置: 首页 > 网络学院 > 客户端脚本教程 > HTML DOM > HTML DOM lang属性
The lang property sets or returns the language code for the element.
lang属性可知识后返回元素的语言代码
bodyObject.lang=language-code |
The following example shows two methods on how to get the language code for the <body> element:
下面的举例将使用两种方法来得到<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> |
Output:
输出
Body language: en-us An alternate way: en-us |
Return the language code for the <body> element
返回<body>元素里代码使用的语言