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.