2012-09-19 2 views

답변

1
var elem = ''; 
$('#divName ul li a').on('click',function(e){ 
    $(this).addClass('active'); 
    elem = $(this); 
    alert(elem); 
    e.preventDefault(); 
}); 


$(window).scroll(function(){ 

    // Use the elem variable here 
    console.log('The Variable this is recently cliked element : '+ elem) 
//for condition a 
//the value of this will a 

//for condition b 
//the value of this will be 
});​ 

확인이 FIDDLE

0

당신이 클릭과 스크롤을 구현하려고 기능성? 스크롤 핸들러 안에 클릭 핸들러를 넣습니다. 클릭이과 같이 정지 할 때 핸들러를 제거해야합니다

$("div").click(function(e) { 
    var target = this; 
    $(window).on("scroll.clickScroll", function(e) { 
     // Use "target" as the reference to what was clicked on. 
    } 
} 

참고 : 나는 정상적인 윈도우 스크롤 및 전문 클릭 스크롤을 구별하기 위해 여기 간격 이벤트 이름을 사용했다

$(window).off("scroll.clickScroll"); 

.

관련 문제