Suppose I have an HTML document that looks like this:
<html lang="en">
...
</html>
My question is: how to get the value of the attribute lang
with jQuery?
I've tried $("html").attr("lang")
but it did not work... any suggestions?
Access the attribute directly, ex :
$('html')[0].lang
You don't need to use jQuery for this.
The easiest way to retrieve the lang
attribute is to access the lang
property on the read-only documentElement
object:
document.documentElement.lang;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With