I would like to change the class for all the fields in a specific fieldset.
Is there a way to loop through the fields in a fieldset?
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.
You can use
getElementsByTagName.(If you only care about
inputfields, you could lose the outer tag loop.)If you needed them in document order (rather than grouped by tag) you’d have to walk over the elements manually, which will be a pain and a bit slow. You could use
fieldset.querySelectorAll('input, textarea, select, button'), but not all browsers support that yet. (In particular, IE6-7 predate it.)