gpt4 book ai didi

javascript - 公开课来后如何去掉附加的h2标签?我正在努力,但没有工作

转载 作者:行者123 更新时间:2023-11-28 19:11:36 24 4
gpt4 key购买 nike

<ul class="nav" id="yui_3_17_2_3_1433409929526_470">
<li class="dropdown open" id="yui_3_17_2_3_1433409929526_469">
<a href="http://192.168.1.112/mth_old_31/moodle28/message/index.php?viewing=recentconversations" class="dropdown-toggle" data-toggle="dropdown" title="Unread messages (5)" id="yui_3_17_2_3_1433409929526_473">
<span id="yui_3_17_2_3_1433409929526_472">5</span>
<i class="fa fa-envelope"></i>
</a>
<ul class="dropdown-menu">
<li class="open"><a title="Admin User will..." href="http://192.168.1.112/mth_old_31/moodle28/message/index.php?user1=2&amp;user2=4">
<div class="message unread">
<span class="msg-picture">
<img src="http://192.168.1.112/mth_old_31/moodle28/theme/image.php?theme=elfin28&amp;component=core&amp;image=u%2Ff1" alt="Picture of student user" title="Picture of student user" class="userpicture defaultuserpic" width="60" height="60">
</span>
<span class="msg-body">
<span class="msg-time">
<i class="fa fa-comments"></i>
</span>
<span class="msg-sender">student</span>
<span class="msg-text">Admin User will...</span>
</span>
</div>
</a>
</li>
</ul>
<h2 id="myid" class="box-messages">Massage</h2>
</li>
<div class="block_action" id="yui_3_17_2_3_1432698699754_495">
<input type="image" class="moveto customcommand requiresjs" alt="Move this to the dock" title="Dock block" src="http://192.168.1.112/mth_old_31/moodle28/theme/elfin28/pix/arrow.png" id="yui_3_17_2_3_1432698699754_494">
</div>
</ul>

<script>
$("#Box1 ul.nav li.dropdown").append('<h2 id="myid" class="box-messages">Massage</h2>');

$( "#Box1 ul.nav li.dropdown.open a span" ).click(function() { $( "h2#myid" ).remove();});
</script>

我正在尝试这样但不起作用。我在哪里工作请帮忙

最佳答案

您需要使用event delegation因为选择器必须稍后评估

$("#Box1 ul.nav").on('click', 'li.dropdown.open a span', function () {
$("#myid").remove();
});

在您的情况下,当您使用 $( "#Box1 ul.nav li.dropdown.open a span") 时, li 没有 open 类,这样点击处理程序就不会被注册。

关于javascript - 公开课来后如何去掉附加的h2标签?我正在努力,但没有工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30640347/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com