How can I, using javascript, loop through all input boxes on a page and clear the data inside of them (making them all blank)?
Share
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.
Try this code:
It’s looping over all
inputelements and it’s setting their value to the empty string.Here is a demo: http://jsfiddle.net/maqVn/1/
And of course if you don’t have jQuery:
Since I prefer the functional style, you can use: