내 사이트에 티켓 시스템이 있습니다. 원래 티켓을 보여준 여러 div와 고객과 직원의 상호 작용을 보여주는이 div 사이에 중첩 된 하위 숨겨진 div가 있습니다. 하나의 div를 열고 다른 것을 닫은 다음 다른 div를 열면 다른 모든 div가 닫히고 닫힌 버튼이 표시됩니다.jQuery 하나의 DIV 클릭하고 다른 DIVS 감지 모두 숨기기
jQuery(document).ready(function() {
// ****** Click the ticket DIV
$(".ticket_thread_7").click(function() {
// Slide the SUB DIVs associated with this ticket
$(".ticket_threads_7").slideDown("slow");
// Turn the arrow from DOWN.png to UP.png
$('.ticket_arrow_7').attr("src", "http://cdn.com/assets/imgs/up.png");
// ****** If they have click the arrow again
}, function() {
// .. close this ticket
$(".ticket_threads_7").slideDown("slow");
// .. also return the image back to normal
$('.ticket_arrow_7').attr("src", "http://cdn.com/assets/imgs/up.png");
return false;
});
});
html로
<div class="ticket_thread_7">
<p>I want to return my order <img src="http://cdn.com/assets/imgs/up.png" class="ticket_arrow_7"></p>
<div class="ticket_threads_7" style="display:none">
<div class="staff_7_1"><p>We cannot accept a return on this item.</p></div>
<div class="cus_7_2"><p>Why not.</p></div>
<div class="staff_7_3"><p>Please visit cdn.com/returnterms to see our policy, apologies.</p></div>
</div>
</div>
이 현재 솔루션은 잘 작동합니다. 네가 상상할 수 있듯이. 이것은 PHP로 구동되는 동적 사이트이므로 사이트에 많은 티켓이 있습니다. jQuery에서 알고 싶습니다. 명령을 사용하여 페이지의 다른 DIV 요소 ID를 모두 숨길 수 있습니다.
그래서 나는 같은 것을 할 수 있습니다 : 그들은 화살표를 클릭 할 때
// Hide all other current open threads and reset their arrows
$(".ticket_threads_7*!=7").slideDown("slow");
$('.ticket_arrow_'*!=7).attr("src", "http://cdn.com/assets/imgs/up.png");
그래서, 개방 경우 모든 다른 스레드가 닫히고 화살표가 초기화되고이 하나가 열립니다.
또는 당신은 할 수 있습니다 (http://css-tricks.com/examples :
You can see a demo here. JsFiddle 소스/ShapesOfCSS /)! – spinningarrow
+1 @spinningarrow - 무슨 소식. – TheBlackBenzKid