【发布时间】:2020-06-17 16:17:21
【问题描述】:
我想使用 jQuery show() 函数在 anchor tag 的 click 上显示 display:none 元素。
但它暂时显示了div 元素然后消失了我使用return false 和preventDefault 函数,但它停止了锚标记的重定向到某个页面。
我该如何解决这个问题?
<div id="assetlist" style="display:none">
@{
Html.RenderPartial("~/Views/Asset/_Asset_List.cshtml");
}
<!-- /.sidebar-menu -->
</div>
<script>
$(document).ready(function () {
$(".asset_managment").click(function(){
$("#assetlist").show();
});
});
</script>
<li class="nav-link" >
<a href="@Url.Action("Index", "Asset")" class="asset_managment">
<img class="img_position" src="@Url.Content("~/admin-lte/img/asset_managment_icon.png")" width="50" height="50" /> Asset Managment
</a>
</li>
【问题讨论】:
-
使用
.hide()而不是.show()See the example here
标签: javascript jquery asp.net-mvc bootstrap-4