她是我的职责。只有当我点击时才认为它不起作用.close-hideme我想删除类noactive并添加类激活
$(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>
答案 0 :(得分:0)
没有HTML很难说,但试试这个(closest()
代替parent()
)。
$(this).closest('tr').find(".bold_blue_img").removeClass("noactive").addClass("active");