【问题标题】:Click Button is not working on a div in asp.net partial page单击按钮不适用于 asp.net 部分页面中的 div
【发布时间】: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


【解决方案1】:

解决了。我在 HTML 中使用了 onclick。

这里是代码。

function CurrentTabDropDown(status) {
    $(status).next('.dummy_current_card_header_dropDownBtn_item').toggle();
}

【讨论】:

    猜你喜欢
    • 2021-11-15
    • 2022-01-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-12-05
    • 1970-01-01
    • 2011-07-10
    • 2012-09-11
    相关资源
    最近更新 更多