【JavaScript】onsubmitイベント
onsubmitイベント
送信ボタンがクリックされた直後で、入力内容がサーバーに送信される直前に発生する。
<使用方法>
取得した要素.onsubmit = function(){
処理内容
};
※イベントに代入するファンクションには、ファンクション名はつけない。
<使用例>
<html>
<section>
<form action="#" id="form">
</form>
</section>
</html>
<script>
document.getElementById('form').onsubmit = function(){
console.log('クリックされました');
}
</script>