문제

Code:

    <script>
$(document).ready(function() {

  $('.sync_box').on('click', function(e){
    e.preventDefault();
    var $btn = $(this);
    $btn.toggleClass('opened');

    var heights = $btn.hasClass('opened') ? 300 : 100 ;
    $('.sync_box').stop().animate({height: heights });
  });
});
    </script>

Where in this script can I add time to slow it down? i am sure this is obvious but i am new to jquery/js so a bit puzzled. Please help. Thanks!

도움이 되었습니까?

해결책 2

$('.sync_box').stop().animate({ height: heights }, TIME_IN_MS);

There buddy.

Be sure to check jquery animate api here.

다른 팁

<script>
$(document).ready(function() {

  $('.sync_box').on('click', function(e){
    e.preventDefault();
    var $btn = $(this);
    $btn.toggleClass('opened');

    var heights = $btn.hasClass('opened') ? 300 : 100 ;
    $('.sync_box').stop().animate({height: heights },2000);
  });
});
</script>

Edited example above. The 2000 is milliseconds.

Reference http://api.jquery.com/animate/

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top