1. 程式人生 > >在button中添加 type="button"和不添加的區別

在button中添加 type="button"和不添加的區別

explore input strong title sea log intern 講解 val

<button type="button" class="btn btn-success" onclick="page.search()">搜索</button>

我在項目中通過按鈕搜索的時候 其中一個頁面沒有給button添加type="button" 時 點擊搜索會重新進入頁面

後臺百度才知道 Internet Explorer 的默認類型是 "button",而其他瀏覽器中(包括 W3C 規範)的默認值是 "submit"。 所以請始終為按鈕規定 type 屬性。

重要事項:如果在 HTML 表單中使用 button 元素,不同的瀏覽器會提交不同的值。Internet Explorer 將提交 <button> 與 <button/> 之間的文本,而其他瀏覽器將提交 value 屬性的內容。請在 HTML 表單中使用 input 元素

來創建按鈕。

詳細講解了 http://www.cnblogs.com/purediy/archive/2012/06/10/2544184.html

在button中添加 type="button"和不添加的區別