Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
89
rated 0 times [  94] [ 5]  / answers: 1 / hits: 39703  / 14 Years ago, thu, february 17, 2011, 12:00:00

In <html> tag I have attribute lang. How do I reach it using .js. I want to use contains of lang as a variable. So as I understand it should start with var lang = ????


More From » jquery

 Answers
133

In jQuery:



    var theLanguage = $('html').attr('lang');
alert(theLanguage);


If you wanna fiddle: http://jsfiddle.net/NX367/



If you want to do it in plain Javascript, this site will explain better than I:

http://www.javascriptkit.com/dhtmltutors/domattribute.shtml


[#93693] Wednesday, February 16, 2011, 14 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
cherish

Total Points: 734
Total Questions: 94
Total Answers: 86

Location: Senegal
Member since Fri, Aug 21, 2020
4 Years ago
;