我对JavaScript比较新。我最近在悬停时发现了这个switch div function。我也插入了下面的代码。我试图插入鼠标已从div中删除后发生的时间延迟。以便它不会立即变回原始文本。我会如何去做这件事?我想我需要使用setTimeOut()
,但我还没有想出一个成功实现它的方法。JavaScript中的切换div功能的时间延迟
$('.switch').hover(function() {
$(this).find('.avg_words').hide();
$(this).find('.avg_num').show();
}, function() {
$(this).find('.avg_num').hide();
$(this).find('.avg_words').show();
});
.avg_num {
\t display: none;
}
<div class="switch">
<div class="avg_words float_left">
A+ (hover to see score)
</div>
<div class="avg_num">
AVG = 98.35%
</div>
</div>
'的setTimeout(函数(){/ *代码在这里* /},延迟);'或'...的setTimeout(functionName,而延迟);' – Jerry