Jump to content

Help with manipulating DOM

- - - - -

  • Please log in to reply
2 replies to this topic

#1
Ryut3k

Ryut3k

    Newbie

  • Members
  • Pip
  • 8 posts
I need help in how to grab the third tag in array <a>

//something like this

var links = document.getElementsByTagName("a[2]");

is this the proper way to do it?

#2
oldhendra

oldhendra

    Learning Programmer

  • Members
  • PipPipPip
  • 30 posts
getElementsByTagName() will get you an array.
So I believe the correct statement should be
var links = document.getElementsByTagName("a")[2];

#3
Ryut3k

Ryut3k

    Newbie

  • Members
  • Pip
  • 8 posts
tried that but still not working even though I think thats the correct way.




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users