JSFiddle - React, Tailwind, and code Playground
by yuezk
HTML
<button>HOVER ME</button>
<div class="tip"></div>
JavaScript
$('button').hover(function () {
var timer = setTimeout(function () {
//ajax请求
//...
//...
$('.tip').show().text('我是延迟出现的');
}, 1500);
$(this).data('preprocess', timer);
}, function () {
$('.tip').hide();
var timer = $(this).data('preprocess');
if (timer) {
clearTimeout(timer);
$(this).data('preprocess', false);
}
});