jQuery加上延迟器
jQuery(document).ready(function() {
var t = $(".dox li"),
b = $(".dox div");
var index = 0;
var timer = null;
if (t.length != b.length) return;
for (var i = 0; i < t.length; i++) {
t[i].id = i;
$(t[i]).mouseover(function() {
var that = this;
////如果存在准备执行的定时器,立即清除;只有当时时间大于100ms开始执行;
if (timer) {
clearTimeout(timer);
timer = null;
}
timer = setTimeout(function() {
for (var j = 0; j < b.length; j++) {
b.css("display", "none");
t.removeClass();
};
// console.log($(that));
// console.log($(b[that.id]));
$(that).addClass('hover');
$(b[that.id]).css("display", "block");
}, 100);
});
};
});