내가하려는 것은 3 초 후에 페이지가로드되고 아무것도 나타나지 않으면 3 초 후에 부분적으로 숨겨집니다. 이제 커서가 상자에 들어가면 제한 시간이 지워지고 광고가 숨겨지지 않습니다.settimeout이 지워지지 않습니다
마우스를 놓고 다시 들어가면 이전 제한 시간이 그대로 유지됩니다. 시간 제한을 지우려고하지만 상자는 여전히 숨겨져 있습니다. 무엇이 문제 일 수 있습니까? (JSfiddle 링크 : http://jsfiddle.net/aK9nB/)
var pstimer;
$(document).ready(function(){
setTimeout(function(){
showps();
pstimer = setTimeout(function() {
hideps();
}, 3000);
}, 3000);
});
$('#psclose').on('click', function(){
$('#postsearch-container').hide();
});
$("#postsearch-container").hover(
function() {
console.log("enter");
clearTimeout(pstimer);
console.log("cleartimeout");
showps();
},
function() {
console.log("leave");
clearTimeout(pstimer);
var pstimer = setTimeout(function(){
hideps();
} , 3000);
});
function showps() {
$("#postsearch-container").stop();
$('#postsearch-container').animate({
bottom: '0'
}, 'slow');
}
function hideps() {
$('#postsearch-container').animate({
bottom: '-115'
}, 'slow');
}
'var pstimer'는 범위 밖에서 접근 할 수없는 새로운 함수 범위 변수를 선언하고 있습니다. 귀하가 선언 한 세계를 ** 설정하지 ** 않습니다. – Shmiddty