【发布时间】:2016-04-27 17:03:28
【问题描述】:
我对 Javascript 比较陌生。我最近在悬停时发现了这个switch div function。我也插入了下面的代码。我试图插入在鼠标从 div 中移除后发生的时间延迟。这样它就不会立即变回原始文本。我该怎么做呢?我想我需要使用setTimeOut(),但我还没有想出成功实现它的方法。
$('.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 {
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(function(){ /* code here */ }, delay);或...setTimeout(functionName, delay);
标签: javascript html time switch-statement delay