jquery - 悬停时显示元素并在悬停结束时隐藏回来

标签 jquery

我想在 #original 悬停时显示 #hover,并带有淡入淡出。当用户停止将鼠标悬停在 #original 上时,#hover 应该淡出。

我正在使用这个代码。使用此功能,该元素会在悬停时显示,但在悬停结束时不会淡出。

$('#hover').hide();

$("#original").hover(function () {
$('#hover').fadeIn('');
});

任何帮助将不胜感激。谢谢,提前。

最佳答案

.hover 有两个回调。

语法

.hover( handlerIn(eventObject), handlerOut(eventObject) );

Description: Bind two handlers to the matched elements, to be executed when the mouse pointer enters and leaves the elements.

$("#original").hover(function () {
  $('#hover').fadeIn();
},function () {
  $('#hover').fadeOut();
});

Official Document

关于jquery - 悬停时显示元素并在悬停结束时隐藏回来,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15583966/

相关文章:

javascript - 在围绕其他元素定位时动态更新多列列表

javascript - 如何从javascript中的另一个函数中的ajax成功访问变量

javascript - jquery.post() 没有重定向到 Rails 中的 View ,而是被 Controller 处理?

php - 将 html 输入作为变量发送到 jquery,然后将其发送到 PHP

javascript - 删除除使用 jQuery 单击的列表项之外的所有其他列表项

来自单独 html 文件的 Javascript 文本预览

javascript - 当输入值达到0时显示按钮

javascript - 使用 jQuery 在悬停时显示菜单子(monad)元素

Javascript/jQuery : How to prevent active input field from being changed?

javascript - 带有下划线和最小出现次数且没有最大出现次数的字母数字字符串模式的正则表达式 - javascript