PHP前端开发

当在HTML中点击表单中的重置按钮时执行脚本?

百变鹏仔 3个月前 (09-22) #HTML
文章标签 表单

当表单被重置时,onreset 属性会触发。您可以尝试运行以下代码来实现onreset属性 −

示例

<!DOCTYPE html><html>   <body>      <form onreset = "display()">         Student Name:<br>         <input type = "text" name = "sname">         <br>         Student Subject:<br>         <input type = "text" name = "ssubject">         <br>         <input type = "reset" value = "reset">      </form>      <script>         function display() {            alert("Form reset successfull!");         }      </script>   </body></html>