提交表单时会触发 onsubmit
属性事件。
没有。
<form onsubmit="script">
<form>, <keygen>
onsubmit |
Yes | Yes | Yes | Yes | Yes |
<!DOCTYPE html>
<html>
<body>
<form action="a.php" onsubmit="myFunction()">
Enter name: <input type="text" name="fname">
<input type="submit" value="Submit">
</form>
<script>
function myFunction() {
console.log("The form was submitted");
}
</script>
</body>
</html>