2013-08-31 4 views
4

IE와 Opera에서 포인터 이벤트가 작동하지 않기 때문에 jQuery를 사용하여 포인터 이벤트 기능을 다시 만들려고합니다.jQuery를 사용하는 포인터 이벤트 기능은 무엇입니까?

나는 위의 사업부가 가리킬 때 애니메이션이 실행되지 않도록 다른 사업부가 및 포인터 이벤트를 갖는 것은 매우 중요합니다 위에 나타 공중 선회 사업부가 있습니다

어떤 생각에서이 작업을 수행하는 방법 jQuery? 나는 몇 가지 시도 (removeClass 같은,로 마우스 등)하지만이 가져올 수 없습니다 :

jQuery를 (시도) :

$(".soc1").hover(function(){ $(".soc1").removeClass("t1") }); 

HTML :

<div class="soc1"><a href="#" target="_blank" class="soc1"><span class="t1">link</span></a></div> 

CSS :

.soc1 a:hover > .t1{ 
    margin-top:-30px; 
    opacity:1; 
} 

.t1{ 
    position:absolute; 
    font-style:normal; 
    letter-spacing:0px; 
    display:block; 
    padding:4px; 
    font-family:Verdana, sans-serif; 
    font-size:10px; 
    color:#fff; 
    background-color:#090909; 
    opacity:0; 
    margin-left:2px; 
    margin-top:-40px; 
    pointer-events:none; 
    cursor:default; 
} 
+1

[포인터 이벤트가 무엇인지 모르는 사람들을위한 mozilla 설명서 링크] (https://developer.mozilla.org/en-US/docs/Web/CSS/pointer-events) 관련 질문 : [Internet Explorer가 포인터 이벤트를 에뮬레이트하도록 만드는 방법] (http://stackoverflow.com/q/9385213/1935077) –

+1

질문에 대한 답변이 좋은이 게시물을보십시오 : http://stackoverflow.com/questions/5855135/css-pointer-events-property-alternative-for-ie –

답변

2

jQuery의 .hover에는 두 가지 기능이 필요합니다. 첫 번째는 마우스가 들어가면 (마우스를 올리면) 두 번째는 마우스가 떠날 때 (h 오버레이)

$(".soc1").hover(function mouseEnters() { 
    $(".soc1").removeClass("t1"); 
}, function mouseLeaves() { 
    $(".soc1").addClass("t1"); 
}); 

주 : "mouseEnters"및 "mouseLeaves"는 선택 사항입니다. 이것들은 「익명 함수」라고 불리고 있습니다. 익명 함수에 대한 이름을 스택 트레이스에서 명확히하기 위해 사용하는 것이 좋다고 생각하지만, 많은 사람들은 익명의 함수를 이름없이 유지하는 것을 선호합니다.