• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

difference between getElementById and getElementByName?

 
André Asantos
Ranch Hand
Posts: 234
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JavaScript - Which are the difference between getElementById and getElementByName?

André AS
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is no getElementByName. There is getElementsByName. Guessing typo there.

getElementById gets an element via an id. getElementsByName returns an Array of elements by their name.

Some horrible browsers will use name if it can not find an id for getElementById and those browsers should be uninstalled and bytes burnt to a crisp.

Eric
 
André Asantos
Ranch Hand
Posts: 234
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
anyway getElementById is more use than other right?

thanks,
André AS
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64205
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please take the time to choose the correct forum for your posts. This forum is for questions on JSP. For more information, please read this.

This post has been moved to a more appropriate forum.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
André Asantos wrote:anyway getElementById is more use than other right?

In my opinion, yes.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64205
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, identifying elements by id is much preferred unless you have a really good reason to need to use the name (which does not have to be unique).
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic