我在asp.net mvc剃刀视图中具有以下Ajax.BeginForm:-
<div id="searchform">
@using (Ajax.BeginForm("AdvanceSearchIndexByName","Home",
new AjaxOptions
{
HttpMethod = "get",
InsertionMode = InsertionMode.Replace,
LoadingElementId = "progress2",
UpdateTargetId = "SearchTable2"
}))
{
}
<input class="btn btn-success" type="submit" value="Clear" id="clear" />
我写了下面的javaScript:
<script type="text/javascript">
$("#clear").on('click', function () {
alert('2');
$('#searchform').clear();
});
</script>
在单击“清除”按钮时重置表单值,但是当前清除按钮没有任何效果.有人可以建议吗?
谢谢
解决方法:
您可以在没有任何JavaScript的情况下执行此操作,只需添加reset type button
@using (Ajax.BeginForm("AdvanceSearchIndexByName","Home",
new AjaxOptions
{
HttpMethod = "get",
InsertionMode = InsertionMode.Replace,
LoadingElementId = "progress2",
UpdateTargetId = "SearchTable2"
}))
{
<input type="reset" value="reset"/>
}