2012-12-11 3 views
1

저는 jquery에서 새로운데, 그것에 대해 많이 알지는 못합니다. 템플릿을 작성 했으므로 필요합니다. 여기 상황이 있습니다. div에 페이지를 삽입하고 싶습니다. 외부 위) 나 링크를 클릭 할 때, 나는 ... 밖으로 미끄러 페이지에 다른 곳을 클릭 할 때 내가 무엇을 가지고 :jQuery를 onclick에서 움직이지 않게하는 방법?

var tmpl_name = '<?php echo $this->template ?>'; 
jQuery(document).ready(function() { 

    jQuery('#link').click(function() { 
    var topy = jQuery('#div'); 
     topy.delay(0).animate({ 
     top: parseInt(topy.css('top')) == 0 ? -topy.outerWidth() : 10 
    },500, 'easeInOutCirc', function() {jQuery(this);}); 
    }); 

}); 

을 ... 내가 클릭 때, 잘 작동 페이지에서 DIV 슬라이드를 연결,하지만 난 사업부를 슬라이드 페이지에서 다른 곳을 클릭하면 달성하는 방법을 모른다, 나는 추가 시도 :

jQuery('body').click(function() { 
    var topy = jQuery('#div'); 
     topy.delay(0).animate({ 
     top: parseInt(topy.css('top')) == 0 ? -topy.outerWidth() : -500 
    },1000, 'easeInOutCirc', function() {jQuery(this);}); 
    }); 

을 ...하지만 때 문제는 d에서 슬라이드하기위한 링크를 클릭하십시오. iv, div는 페이지의 내부 및 외부로 이동합니다 (링크가 본문에 있기 때문에 코드의 두 번째 부분에도 영향을 미칩니다).

시간 내 주셔서 감사합니다 ... 감사합니다

답변

0

.stop() 기능은 어떤 애니메이션을 중지 끝에뿐만 아니라 통화의 시작 부분에 체인 수 있습니다.

$("#element").stop().bounce().stop();

2

시도 :

jQuery(document).ready(function() { 

    jQuery('#link').click(function(e) { 
    e.preventDefault(); 
    var topy = jQuery('#div'); 
     topy.delay(0).animate({ 
     top: parseInt(topy.css('top')) == 0 ? -topy.outerWidth() : 10 
    },500, 'easeInOutCirc', function() {jQuery(this);}); 
    }); 

}); 

문서 객체에 이벤트 전파를 죽일

관련 문제