JavaScript document.getElementsByName

JavaScript document.getElementsByName method performs similar to the combination of getElementsById and getElementsByTagName methods. Document getElementsByName method returns the collection of HTML elements according to the specified name i.e. the value of name attribute of HTML elements. You can specify the same "name" attribute value for HTML elements to create a group of items having similar "name". JavaScript getElementsByName method generates the collection of HTML elements having same "name" attribute value that further provides various properties and methods to dynamically manipulate the HTML objects available in the collection.

Try the sample code below to learn and practice the document.getElementsByName method functionality and loop over the collection of elements to access their properties:

Edit this code and click update to view output
OUTPUT:
  • HIRE EzineASP.Net Developers