Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

id and name  RSS feed

 
mark I thomas
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator



what's the difference between "id" and "name" ? which one should be used when we access this element via using javascript ?
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65830
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The id attribute assignes an identifier to any element in the DOM for use in client-side scripting. The name attribute is applicable only to form elements and is used to assign the name for the submission parameter for that form element.

So, in short:
  • id is used in JavaScript on the client
  • name is used on the server to collect request parameters.


  • Older JavaScript used the names as part of client-side addressing, but that's antiquated and fragile and should no longer be done that way.
     
    With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
    • Post Reply Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!