我正试图让特定的DIV在链接上空盘旋时保持打开状态。 我正在触发< hoverintent a>,但它在mouseleave上消失了。这是预期的,因为hoverintent仅限于< a>但你怎么设置它以便在另一个div上保持开放状态呢?
<a href="#divid" class="my-class">
<span class="linkText">Link Text</span>
</a>
<div id="divid" class="keepopen"><p> Content </p> </div>
所以当我悬停时,我在“keepopen”上添加了一个类,我想确保当它悬停在它上面时它不会消失。除了&lt;之外,我还必须将hoverintent绑定到此div吗? a&gt;?
JS很长,但这里是具体的区域: 在这个$(this)中传递了&lt; a&gt;与我的特定css类,它是一个更大的功能。我也为键盘焦点和模糊和触摸事件定制了它。
//6. Configuration settings for HoverIntent plugin
var config = {
sensitivity: 2, // number = sensitivity threshold (must be 1 or higher)
interval: defaults.hoverDelay, // number = milliseconds for onMouseOver polling interval
over: linkOver, // function = onMouseOver callback (REQUIRED)
timeout: defaults.hoveroutDelay, // number = milliseconds delay before onMouseOut
out: linkOut // function = onMouseOut callback (REQUIRED)
};
//7. If Touch alter the bindings
if (!defaults.isTouch) {
// Initialise HoverIntent
$(this).hoverIntent(config);
//Click, Focus, Focusout, Blur
$(this).on('click', function () {
return false;
});
$(this).on('focus', linkOver);
$(this).on('blur focusout', linkOut);
} else {
// Touch Only Event Binding
$('body').on('touchend', linkOut);
$(this).on('touchstart', linkOver);
$(this).on('touchstart touchend', function (e) {
e.stopPropagation();
e.preventDefault();
});
$tooltip.on('touchstart touchend', function (e) {
e.stopPropagation();
});
}