在 HTML 中,当表单中的重置按钮被点击时执行脚本?
htmlweb developmentfront end technology更新于 2025/8/16 1:16:17
当表单重置时,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>
相关文章
有用资源
html 参考教程 - 该教程包含有关 html 的更多信息:https://www.cainiaomax.com/html/

