重置按钮用于重置HTML表单中的所有输入字段。它是使用<input>标签的属性type添加的。
定义一个重置按钮,它将所有表单值重置为其初始值。
<input type="reset">
下面给出了在 HTML 表单中实现重置按钮的使用的示例 -
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <meta name="description" content="meta tag in the web document"> <meta name="keywords" content="HTML,CSS"> <meta name="author" content="lokesh"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> </head> <body> <form> Enter Name<br> <input type="text" name="Ename"> <br> Enter Age<br> <input type="text" name="Eage"> <br> Enter Address<br> <input type="text" name="Eaddress"> <br><br> <input type="reset" value="reset"> </form> </body> </html>
您可以尝试运行以下代码来重置 HTML 表单中的按钮 -
<!DOCTYPE html> <html> <body> <form> Student Name:<br> <input type="text" name="sname"> <br> Student Subject:<br> <input type="text" name="ssubject"> <br> <input type="reset" value="reset"> </form> </body> </html>