技巧就是把提交的input的類型改爲button!這樣就能夠實現多個按鈕提交!javascript
如下是案例:java
<form action="" id="tijiao"> <input type="text" value="" name="ceshi"> <button class="btn btn-sm btn-success" id="bt_search">查詢結果</button> | <button class="btn btn-sm btn-success" id="bt_output">數據導出</button> </form>
<script type="text/javascript"> jQuery(function($) { // 條件查詢 $("#bt_search").click(function(){ $("#ljz-form-search").removeAttr('action'); $("#ljz-form-search").attr('action',"{:U('Admin/Member/searchMember')}" ); $("#ljz-form-search").submit(); }); // 數據導出成excel表格 $("#bt_output").click(function(){ $("#ljz-form-search").removeAttr('action'); $("#ljz-form-search").attr('action',"{:U('Admin/Member/outputMembersExcel')}" ); $("#ljz-form-search").submit(); }); }) </script>
這個能夠用來作一個頁面中有多個提交按鈕的狀況!!spa