简体   繁体   中英

Onsubmit function called submit

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>

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM