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?
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?
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; Use .attr()
alert($('html').attr('lang'));