모두, 중첩 요소 가리개 처리기를 다루는 문제가 있습니다. 그것은 것 같습니다 마우스 child
div 입력 할 때, 조상은 hover
상태에 있습니다, 어떤 방법으로 조상의 hoverout
이벤트를 방아쇠를 당길 때, child
요소를 입력하십시오?중첩 요소가 가리키는 핸들
다음은 지금까지 내가 작성한 것입니다. 검토해주십시오.
<style>
div
{
border:1px solid red;
margin:10px;
padding:10px;
}
</style>
<script>
$(function() {
$('div').each(function(){
var current = this;
$(this).hover(function(event){
event.stopPropagation();// doesn't work.
console.log('Capture for hover in ' + current.tagName + '#'+ current.id +
' target is ' + event.target.id); },
function(event){
event.stopPropagation();
console.log('Capture for hover out' + current.tagName + '#'+ current.id +
' target is ' + event.target.id); });
});
});
</script>
<body id="greatgrandpa">
<div id="grandpa">
<div id="parent">
<div id="child"/>
</div>
</div>
</body>
별표를 제거하고 이미지에서 기능을 실행하십시오. ***에서 반복되는 루프 내에서 이벤트 처리기를 연결합니다 *** 모든 요소! – adeneo
안녕하세요, 아데노, 방금 질문을 명확하게 업데이트합니다. 그것을 검토해주십시오. 감사합니다. –
나는 정말로 그것을 얻지 못한다. 그러나 당신은 mouseenter/leave 기능을 원하는대로 설정할 수있다. [** FIDDLE **] (http://jsfiddle.net/FXU65/) ?? – adeneo