gpt4 book ai didi

jquery - 无法正确选择 JQuery

转载 作者:太空宇宙 更新时间:2023-11-04 05:23:37 25 4
gpt4 key购买 nike

我正在尝试在单击时将边框添加到 li 中。这是我的代码。

<div class="noselect round" id="teach_edit_navigation_holster">
<ul id="teach_edit_navigation">
<li id="edittab_one" class="teach_nav_roundleft">
<span>Item</span>
</li>
<li class="" id="edittab_two">
<span>Item</span>
</li>
<li class="" id="edittab_three">
<span>Documents</span>
</li>
<li class="" id="edittab_four">
<span>Item</span>
</li>
<li class="" id="edittab_five">
<span>Item</span>
</li>
<li class="teach_nav_roundright" id="edittab_six">
<span>Item</span>
</li>
</ul>
</div>

这是 Jquery。我希望整个 li 框上有边框,而不是跨度。下面的代码在跨度上放置了一个边框。我不知道如何选择实际的 li。谢谢!

  $(document).ready(function () {
$('#edittab_two_s, #edittab_three_s, #edittab_four_s, #edittab_five_s, #edittab_six_s').hide();
// $('#teach_edit_navigation').find('#edittab_one').css({
// "background-color": "black" // set highlight to first item on page "home"
// });
});

$('#teach_edit_navigation_holster li').click(function () {
var Vinfotab = this.id + '_s',
$this = $(this);
$('.edittab:visible').fadeOut('fast', function () {
$('#' + Vinfotab).fadeIn('fast');
$('#teach_edit_navigation_holster li span').css({
"border": "none" // reset all to default color
});
$this.find('span').css({
"border-bottom": "1px solid black" // set highlight to this element only
});
});
});

最佳答案

<li>$this 表示.这应该适合你:

$('#teach_edit_navigation_holster li').css({ // !!! remove span
"border": "none" // reset all to default color
});
$this.css({ // !!! remove .find('span')
"border-bottom": "1px solid black" // set highlight to this element only
});

关于jquery - 无法正确选择 JQuery,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5851214/

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