document.getElementById('frmMain').elements
can i use like this
document.getElementByName('frmMain').elements
or
document.getElementBytag('table').elements`
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
assumes the form has an ID and that the ID is unique as IDs should be. Although it also accesses a
nameattribute in IE, please add ID to the element if you want to use getElementByIdwill get the elements of the first object named frmMain on the page – notice the plural getElements – it will return a collection.
will get the elements of the first form on the page based on the tag – again notice the plural getElements
A great alternative is
will get the elements of the first form on the page. The “form” is a valid CSS selector
notice the
All– it is a collection. The [0] will get the elements of the first form on the page. The “form” is a valid CSS selectorIn all of the above, the
.elementscan be replaced by for example.querySelectorAll("[type=text]")to get all text elements