Onsubmit function called submit

做~自己de王妃 提交于 2019-11-28 13:47:33

问题


I am wondering why onsubmit global scoped function cannot be called submit. I didnt find any reason.

This doesnt work:

<form onsubmit="return submit();">
    <input type="submit">
</form>
<script>
    function submit() { alert('Hey!'); return false; }
</script>

This does work:

<form onsubmit="return test();">
    <input type="submit">
</form>
<script>
    function test() { alert('Hey!'); return false; }
</script>

回答1:


Here is a list of Javascript's reserved words. As you can see, submit is one of them !



来源:https://stackoverflow.com/questions/35395433/onsubmit-function-called-submit

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!