2011-12-02 8 views

답변

6
$(document).ready(function() { 
    $("#wrapper").bind('mousemove', function(e) { 
     $("#tail").css({ 
      top: e.pageY 
     }); 
    }); 
}); 

추가는 : 시작 위치로 백업하려면 :

$(document).ready(function() { 
    $("#wrapper").hover(function() { 
     $.data(this, "tail_Y", $("#tail").css("top")); 
    }, function() { 
     $("#tail").css("top", $.data(this, "tail_Y")); 
    }).bind('mousemove', function(e) { 
     $("#tail").css({ 
      top: e.pageY 
     }); 
    }); 
}); 

http://jsfiddle.net/1stein/VWEEB/

+0

환상적인, 꼬리는 다시 원래 위치로 스냅하기위한 방법은 무엇입니까? 마우스 아웃시 CSS 기능을 제거 하시겠습니까? – uriah

+0

@uriah : [this] (http://jsfiddle.net/dzejkej/VWEEB/3/) 당신이 원하는 것은 무엇입니까? – kubetz

+0

@dzejkej 예! 대단히 감사합니다. – uriah

0

수도 도움

$(document).bind('mousemove', function(e){ 
    $('#tail').css({ 
     top: e.pageY 
    }); 
    $('#wrapper').click(function(){  
    xyz(); 

    }); 
}); 


function xyz() 
{ 
     alert('hello'); 
} 
0

을이 시도 :

$("#wrapper").mouseover(function() { 
    // your function here 
    alert("mouse over red area"); 
}); 

Example fiddle here

0

당신은 DOM이 준비되면이 코드를 실행할 수 있는지 확인해야합니다 :

$("#wrapper").bind('mouseenter', function(e) { 
    alert("Entered Wrapper") 
});