通过JavaScript重置表单(reset)的方法,下面的代码可以对表单内的输入数据进行重置
<!DOCTYPE html> <html> <head> <script> function formReset() { document.getElementById("frm1").reset(); } </script> </head> <body> <p>Enter some text in the fields below, then press the "Reset form" button to reset the form.</p> <form id="frm1"> First name: <input type="text" name="fname"><br> Last name: <input type="text" name="lname"><br><br> <input type="button" onclick="formReset()" value="Reset form"> </form> </body> </html>