0
현재 클래스를 추가/제거하기 위해 일부 jQuery를 실행 중입니다. 그것은 형제 자매들과 잘 작동하지만 형제 자매들과는 잘 맞지 않습니다. 아무나 좋은 생각이있어?jQuery가 클래스를 제거하지 않는 이유
$('#rotator_buttons td').click(function(){
if($(this).hasClass('current')) {
$(this).removeClass('current');
}
else {
$(this).addClass('current').siblings().removeClass('current');
$(this).siblings().children('a').removeClass('current');
$(this).children('a').addClass('current');
}
return false;
});
HTML
<table id="rotator_buttons">
<tbody>
<tr>
<td id="pause-play"><a href="#"><!-- --></a></td>
<td><a href="#" id="1" target="_self" onclick="javascript:increment_slideshow(0)">Button 1</a></td>
<td><a href="#" id="2" target="_self" onclick="javascript:increment_slideshow(0)">Button 2</a></td>
<td><a href="#" id="3" target="_self" onclick="javascript:increment_slideshow(0)">Button 3</a></td>
<td><a href="#" id="4" target="_self" onclick="javascript:increment_slideshow(0)">Button 4</a></td>
</tr>
는 실제로 자녀, 또는 깊은 중첩입니까? DOM을 볼 수 없을 때 DOM 선택 질문에 대답하는 것은 거의 불가능합니다. –
클래스'current'가 사용되는 위치에 따라'$ (this) .parent(). find ('.current'). removeClass ('current')'를하고 싶을 수도 있습니다. –