-1
다른 사용자가이 기능이 작동하지 않는 이유를 지적 할 수 있습니까? 나는 Container Div 내의 Div A를 클릭하려고 시도하고있다. 그리고 클릭 할 때, 부모 컨테이너까지 올라가 다음 Div B를 찾고, 그 가시성을 토글한다.클릭하면 형제 div 요소가 확장됩니다.
참고 : 내가 이렇게하는 이유는 모든 하위 항목을 '하위'클래스와 함께 표시하고 싶지 않기 때문입니다. 상위 div 다음의 다음 항목 만
http://jsfiddle.net/vecalciskay/54HxU/5/
HTML :
<div class="container">
<div class="parent">
<span> Parent Text (click) </span>
</div>
<div class="child">
<table>
<tr>
<td>
This
</td>
<td>
Table
</td>
</tr>
<tr>
<td>
Should
</td>
<td>
Expand
</td>
</tr>
</table>
</div>
<div class="parent">
<span> Parent 2 (don't click) </span>
</div>
<div class="child">
<table>
<tr>
<td>
This
</td>
<td>
Table
</td>
</tr>
<tr>
<td>
Should Not
</td>
<td>
Expand
</td>
</tr>
</table>
</div>
JQUERY : 모든 의견에
$(document).ready(function() {
$('.child').hide();
$('.parent').click(function() {
var obj = $(this).parent().next(".child");
obj.toggle("fast");
return false;
});
});
누락 된 부분이 있습니까? 당신의 바이올린은 작동하지 않습니까? – j08691
게다가,'$ ('. parent'). parent()'는'.container'를 반환합니다; '.next ('. child')'분명히 잘못된 항목을 선택합니다. –
바이올린이 작동하고있는 것처럼 보입니다. –