1. 程式人生 > >form中的button默認提交事件

form中的button默認提交事件

button input off send 修改 code NPU text put

    <form action="">
        <input autocomplete="off" type="text" name="" id="m">         
        <button>Send</button>
    </form>    

在form中的button默認的時候點擊時間會執行form的提交事件(相當於默認為submit類型)

如果需要阻止它:

    <form action="">
        <input autocomplete="off"
type="text" name="" id="m"> <button type=‘button‘>Send</button> </form>

將button的type修改為button可以阻止

form中的button默認提交事件