2013-04-15 3 views
1

.folder을 클릭하여 표시하고 나머지 모든 콘텐츠를 숨기려고합니다. 파일 브라우저처럼.자녀를 표시하고 부모를 숨기기

+0

내가 물어 봐도 될까요? 사용자의 하드 드라이브와 상호 작용하는 경우 간단한 파일 브라우저를 표시 할 수있는 IO 클래스가 있어야합니다. – Jeff

+0

사용자의 하드 드라이브와 전혀 상호 작용하지 않습니다. 서버 측에서 파일 나열. – Kivylius

+0

http://jsfiddle.net/ 무엇이 작동하지 않습니까? – DerStoffel

답변

0
$('ul li.folder').on('click',function(e){ 

    $(this).siblings('li').toggle(); 
    $(this).children().toggle(); 
    e.stopPropagation(); 
}); 

이 작동해야 jQuery를 siblings() selector.를 사용하여 시도 할 수 있습니다. 당신은 단순히 파일 브라우저를 사용 할 수없는 이유

1

당신은

$('.folder').on('click',function(e){ 
    $(this).children().toggle(); 
    $(this).siblings('li.folder').children().toggle(); 
    e.stopPropagation(); 
}); 
+0

이것은 거의 완벽하게 작동하지만 2/3/4는 그렇지 않습니다. 레벨 깊이 목록의 – Kivylius

+0

그것으로 놀아 라. 다른 선택기 (.parent()? .children()를 사용해야 할 수도 있습니다. 의도하지 않은 동작이 보이는가요? 시도해보십시오. 재미 있습니다. – Jeff

0

Sample

//toggle children and siblings 
$('.folder').on('click',function(e){ 
    $(this).children().toggle(); 
    $(this).siblings().toggle(); 
    e.stopPropagation(); 
}); 
//cancel file clicks 
$('.file').on('click', function(e) { 
    e.stopPropagation(); 
    return false; 
}); 
관련 문제