锚点标记是否作为表单提交按钮?
<form method="get" action="<?php bloginfo('url'); ?>/">
<div class="field-search">
<input type="text" class="form-control input-lg" placeholder="Search for..." value="<?php the_search_query(); ?>">
<a href="#" class="btn-search"><i class="fa fa-search font-16"></i></a>
</div>
答案 0 :(得分:0)
<form action="test.aspx" type="POST">
<label>
<span>Username</span>
<input type="text" name="UserName" id="UserName" class="input-text required" />
</label>
<label>
<span>Password</span>
<input type="password" name="Password" id="Password" class="input-text required" />
</label>
<label>
<input type="checkbox" name="RememberMe" id="RememberMe" class="check-box" />
<span class="checkboxlabel">Remember Me</span>
</label>
<div class="spacer">
<a href="javascript:void(0)" class="login-button">Login</a>
</div>
</form>
jquery的
$(document).ready(function(){
$(document).on("click",".login-button",function(){
var form = $(this).closest("form");
//console.log(form);
form.submit();
});
});
可能重复 (Anchor tag as submit button?)
(这是复制的答案)
答案 1 :(得分:0)
尝试这种方法,看看它是否有效。
将click事件添加到您的锚标记,如下所示并执行event.stopPropagation()
$('a').on('click', function(e){
e.stopPropagation();
})`
看看是否有效