我想在锚点悬停时显示和隐藏一个工具提示。但是工具提示应该一直存在,直到我的光标停留在上面。
fiddle
$('#showReasonTip').mouseover(function(){
$(this).parent().find('#reasonTip').slideDown()}).mouseout(function(){
$(this).parent().find('#reasonTip').slideUp()
}
)
提前致谢。
最佳答案
尝试
jQuery(function ($) {
$('#showReasonTip').hover(function () {
var $target = $('#reasonTip');
clearTimeout($target.data('hoverTimer'));
$target.stop(true, true).slideDown();
}, function () {
var $target = $('#reasonTip');
var timer = setTimeout(function () {
$target.stop(true, true).slideUp();
}, 200);
$target.data('hoverTimer', timer);
});
$($('#reasonTip')).hover(function () {
clearTimeout($(this).data('hoverTimer'));
}, function () {
$(this).stop(true, true).slideUp();
});
});
演示:Fiddle
关于javascript - onmouseover显示/隐藏div并可以选择div的文本,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/20559988/