2013-01-06 4 views
0

토글 후 프로그래밍 방식으로 가시성을 설정해야하는 div "pastmeet"에 jQuery 토글이 있습니다. div에 대한 스타일을 display : block으로 설정했습니다. jQuery에 (쇼)를 추가 한 다음 CSS를 변경했습니다. 어떤 일을하던간에 div는 표시되지 않으며 소스 코드는 div에 표시가 할당되었음을 보여줍니다 : none. 토글이 꺼진 후에 div를 어떻게 표시합니까? 그냥 쇼를 전환하고 숨기려면 당신은 사용할 수토글 후 jQuery로 가시성을 변경하는 방법

(function ($) { 
     $(document).ready(function() { 
      $(".div_toggle").slideUp(); 
      $(".toggle_action").click(function(){ 
      $(this).next(".div_toggle").slideToggle("slow"); 
     }); 
     $('.pastmeet').css('display', 'block'); // force visibility to on   
     return false; 
    });   
    })(jQuery); 

답변

0

:

$(".toggle_action").click(function(){ 
     $(this).next(".div_toggle").toggle(); 
    }); 

을하지만, 당신이 뭔가 더 사용자 정의해야 할 경우이 내가 '무엇을 여기에 기존 코드의 과거에 한 일 :

var showHide = 0; 
    $(".toggle_action").click(function(){ 
     if (showHide == 0) { 
       showHide = 1; 
       $(this).next(".div_toggle").hide(); 
      //do something 
     } else { 
       showHide = 0; 
       $(this).next(".div_toggle").show(); 
      //do something 
    }); 
+0

감사합니다. Losbear! 이것은 매우 도움이됩니다! – longboardnode

관련 문제