最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to cancel form submit for btn-primary within form-actions of Twitter Bootstrap? - Stack Overflow

programmeradmin1浏览0评论
<div class="form-actions">
  <button class="btn btn-primary" id="btn-next">Next</button>
  <button type="reset" class="btn">Reset</button>
</div>

$("#btn-next").click(function(event) {
    $('#tab li.active').next().find('a[data-toggle="tab"]').click();
});

When Next is pressed, form is submitted. How can I cancel it? demo

<div class="form-actions">
  <button class="btn btn-primary" id="btn-next">Next</button>
  <button type="reset" class="btn">Reset</button>
</div>

$("#btn-next").click(function(event) {
    $('#tab li.active').next().find('a[data-toggle="tab"]').click();
});

When Next is pressed, form is submitted. How can I cancel it? demo

Share Improve this question asked Feb 14, 2012 at 17:13 LA_LA_ 20.4k60 gold badges179 silver badges318 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 9

Make it an anchor, not a button:

<a class="btn btn-primary" id="btn-next">Next</a>

Just return false from the click handler.

$("#btn-next").click(function(event) {
    $('#tab li.active').next().find('a[data-toggle="tab"]').click();
    return false;
});

Demo

发布评论

评论列表(0)

  1. 暂无评论