【发布时间】:2021-09-05 22:47:06
【问题描述】:
我在 .NET MVC 项目中使用 JQUERY 3.4.1。当我获取部分页面时,点击不起作用。在这里,我放了我尝试过的代码。当我使用 $(document).on('click') 时,它正在创建另一个问题,即它也在打开选项卡数据。所以我避免了。
$(document).on('click', '.dummy_current_card_header_dropDownBtn', function () {
$(this).next('.dummy_current_card_header_dropDownBtn_item').toggle();
});
// project_lesting_current_card_header_dropDownBtn
$('.dummy_current_card_header_dropDownBtn').on('click', function () {
$(this).next('.dummy_current_card_header_dropDownBtn_item').toggle();
});
$('.dummy_current_card_header_dropDownBtn').click(function () {
$(this).next('.dummy_current_card_header_dropDownBtn_item').toggle();
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="current_card_header_btn">
<span class="current_card_header_dropDownBtn dummy_current_card_header_dropDownBtn" type="button" role="button"><img src="~/images/project/icon/action_icon.png" style="width: 14px;"></span>
<div class="current_card_header_dropDownBtn_item dummy_current_card_header_dropDownBtn_item">
<ul>
<li><a href="#" type="button" role="button">Review</a></li>
<li><a href="#" type="button" role="button">Duplicate</a></li>
<li><a href="#" type="button" role="button">Archive</a></li>
<li><a href="#" type="button" role="button">Delete</a></li>
</ul>
</div>
</div>
【问题讨论】:
-
在代码 sn-p 中,单击
.dummy_current_card_header_dropDownBtn会切换列表项。什么不工作?
标签: javascript html jquery asp.net-mvc