如何使用JavaScript获取HTML中的lang属性?


80

如何lang使用JavaScript获取HTML中的属性?

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

Answers:



27

只是。

document.getElementsByTagName('html')[0].getAttribute('lang');

并与命名空间

document.getElementsByTagName('html')[0].getAttribute('xml:lang');
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.