gpt4 book ai didi

jquery - 不同元素的多个切换添加删除类

转载 作者:太空宇宙 更新时间:2023-11-03 18:45:02 25 4
gpt4 key购买 nike

她是我的职责。只有当我单击 .close-hideme 时才认为它不起作用我想删除类 noactive 并添加类 active

$(function () {    
var text = $(this).text();
$(".hideme").hide();
var elements = $(".bold_blue, .bold_blue_img");
elements.click(function () {
var element = $(this);
elements.removeClass("active");
if (text == 'dot' || text == '+' && !$(".hideme").is(":visible")) {
$(this).closest('tr').find(".bold_blue_img").text($(this).closest('tr').find(".bold_blue_img").text() == '-' ? '+' : '-');
$(this).closest('tr').find(".bold_blue_img").removeClass("active").addClass("noactive");
return false;
}
else {
$(this).parents("tr").next().slideToggle("slow");
$(this).closest('tr').find(".bold_blue_img").text($(this).closest('tr').find(".bold_blue_img").text() == '-' ? '+' : '-');
$(this).closest('tr').find(".bold_blue_img").toggleClass('noactive');
return false;
}
});
$('.close-hideme').bind('click', function () {
if (!$(".hideme").is(":visible")) {
$(this).closest('tr').find(".bold_blue_img").removeClass("noactive").addClass("active");
$(this).parents(".hideme").hide("slow");
return false;
}
});
});

任何人都知道如何将该类更改为事件类,这里是 html 代码

<table style="width:100%">   
<tbody>
<tr class="parent">
<td><a class="bold_blue">dot</a><a class="bold_blue_img active">+</a>
<!-- i've to use 2 different hrefs here plus is text only but inside css there is class active and noactive with background images -->
</td>
</tr>
<tr class="hideme">
<td><a class="close-hideme right">X</a>
<!-- this button is not working, i mean is hiding but is not changing bold_blue_img class to active -->
</td>
</tr>
</tbody>
</table>

最佳答案

没有 HTML 很难说,但试试这个(closest() 而不是 parent())。

$(this).closest('tr').find(".bold_blue_img").removeClass("noactive").addClass("active"); 

关于jquery - 不同元素的多个切换添加删除类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16566672/

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