JavaScript 中 onreset 事件的使用是什么?


当表单重置时,onreset 事件非常有用。你可以尝试运行以下代码以了解如何在 JavaScript 中实现 onreset 事件 -

示例

<!DOCTYPE html>
<html>
   <body>
      <script>
         function resetFunct() {
            alert("The form was reset");
         }
      </script>
      <form onreset = "resetFunct()">
         Enter age: <input type = "number"><br>
         Enter birth month: <input type = "text"><br>
         <input type = "reset">
      </form>
   </body>
</html>

更新于: 2020-06-23

291 浏览

开启你的 职业

完成课程以获得认证

开始
广告
© . All rights reserved.