JavaScript를 사용하여 이미지를 숨기고 그 아래에 숨겨진 텍스트를 표시하고 있습니다. 그러나 텍스트를 스크롤하면 텍스트가 표시 될 때 컨테이너에서 mouseout 이벤트가 발생하고 텍스트가 숨겨지고 이미지가 다시 표시되며 이상한 루프가 발생합니다.mouseout 이벤트 문제
<div onmouseover="jsHoverIn('1')"
onmouseout="jsHoverOut('1')">
<div id="image1" />
<div id="text1" style="display: none;">
<p>some content</p>
<p>some more content</p>
</div>
</div>
그리고 자바 스크립트는 (은 script.aculo.us의 사용) :
HTML은 다음과 같습니다
function jsHoverIn(id) {
if(!visible[id]) {
new Effect.Fade ("image" + id, {queue: { position: 'end', scope: id } });
new Effect.Appear ("text" + id, {queue: { position: 'end', scope: id } });
visible[id] = true;
}
}
function jsHoverOut (id) {
var scope = Effect.Queues.get(id);
scope.each(function(effect) { effect.cancel(); });
new Effect.Fade ("text" + id, {queue: { position: 'end', scope: id } });
new Effect.Appear ("image" + id, {queue: { position: 'end', scope: id } });
visible[id] = false;
}
이 정말 간단한데,하지만 난 그냥 질수가 주위에 내 머리를 정리.
DIV의 높이를 상위 (즉, 세로 막대)의 높이로 만들려는 경우에도 사용할 수 있습니다. "text1"DIV에 추가 DIV에 의해 방해받는 앵커가 포함 된 경우 위의 내용은 유용하지 않습니다. –