Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Aug 2005
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Extracting HTML tag information

    Is it possible to extract out information from the HTML tag using JavaScript? For example, is it possible to extract the value of the 'lang' attribute from the HTML tag?

    Any help would be appreciated.

    Cheers,
    Marty

  • #2
    Senior Coder
    Join Date
    Feb 2003
    Posts
    1,665
    Thanks
    0
    Thanked 27 Times in 25 Posts
    Code:
    document.getElementsByTagName('html')[0].lang

  • #3
    New Coder
    Join Date
    Aug 2005
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks mate... I had been doing it with 'Name' not 'TagName'... duh... many thanks indeed.
    Marty

  • #4
    Senior Coder
    Join Date
    Feb 2003
    Posts
    1,665
    Thanks
    0
    Thanked 27 Times in 25 Posts
    Quote Originally Posted by martyf
    Thanks mate... I had been doing it with 'Name' not 'TagName'... duh... many thanks indeed.
    Marty
    Note also that it's getElements - i.e. plural

    It creates an array. The [0] is used to select the first item in that array (javascript array indexes begin at 0).


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •