这是我的模式在twitter bootstrap中的代码:
<div class="modal-body"> <form class="form-horizontal" method="POST" name="loginForm" id="loginForm"> <div class="control-group"> <label class="control-label" for="inputEmail">Email</label> <div class="controls"> <div class="input-prepend"> <span class="add-on"><i class="icon-envelope"></i></span> <input class="span2" id="inputIcon" type="text" name="email"/> </div> </div> </div> <div class="control-group"> <label class="control-label" for="inputPassword">Password</label> <div class="controls"> <div class="input-prepend"> <span class="add-on"><i class="icon-lock"></i></span> <input class="span2" id="password" type="password" name="password"/> </div> </div> </div> <div class="control-group"> <div class="controls"> <label class="checkBox"> <input type="checkBox"> Remember me </label> </form> <button type="submit" class="btn" id="signin_button">Sign in</button> </div> </div>
解决方法
您可以防止提交页面的按钮的默认行为.
以下是Mozilla开发人员网络中“preventDefault”的链接:event.preventDefault
在jQuery中,您可以这样做:
$("#signin_button").on("click",function(e) { e.preventDefault(); // the rest of your code ... });