本文介绍了onclick和onsubmit有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

这好像不是我没有用谷歌搜索过……但是我还是不明白何时使用onsubmit和何时使用onclick?

It's not like I haven't googled it... But still I couldn't understand when onsubmit is used and when onclick is used?

推荐答案

它们是两个完全独立的事件.

They're two completely separate events.

onclick事件.

onsubmit事件.该事件的起源有时可以追溯到onclick(如单击提交"按钮),但也可以来自键盘事件(如按).

onsubmit events fire when a form is submitted. The origin of this event can sometimes be traced back to an onclick (like clicking the "submit" button) but it can also come from a keyboard event (like pressing ).

这意味着在表单上的提交"按钮上使用onclick可能会丢失某些表单上的onsubmit会捕获的情况.

This implies that using onclick on a submit button on a form might miss some cases that an onsubmit on the form would catch.

还有许多其他类型的事件,例如:onload用于加载脚本或图像等资源,以及onkeydown用于检测键盘上的按键按下.

There are many other kinds of events such as: onload for loading resources such as scripts or images and onkeydown for detecting key presses on the keyboard.

这篇关于onclick和onsubmit有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-06 12:27