jQuery 悬停效果

发布于 2024-10-10 06:59:08 字数 150 浏览 0 评论 0原文

我正在尝试达到这种效果http://www.un.org/。这意味着您有不同的链接,将鼠标悬停在下面会出现相应的文本。是否可以使用 jQuery 来实现这一点?

感谢您的帮助

I'm trying to have this effect http://www.un.org/. Meaning you have different links, on hover the corresponding text appear below. Is it possible to achieve this using jQuery?

Thanks for helping

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

悲欢浪云 2024-10-17 06:59:08

您可以单独使用 CSS

<a href="#">My Link<span>My Hover Text</span></a>

a span { display: none; }
a:hover span { display: inline; }

http://jsfiddle.net/TkVtm/

来完成此操作,或者对于更复杂的场景,您可以可以使用jQuery做一个简单的悬停效果:

$("#links li").hover(function() {
    $("#text li:eq(" + $(this).index() + ")").toggle();
});

http://jsfiddle.net/TkVtm/1/

You can do this with CSS alone

<a href="#">My Link<span>My Hover Text</span></a>

a span { display: none; }
a:hover span { display: inline; }

http://jsfiddle.net/TkVtm/

or for a more complex scenario you can use jQuery to do a simple hover effect:

$("#links li").hover(function() {
    $("#text li:eq(" + $(this).index() + ")").toggle();
});

http://jsfiddle.net/TkVtm/1/

疧_╮線 2024-10-17 06:59:08

您可以使用 jQuery Hover() 事件,只需更改包含相应文本的 div :

$("#hoverArea").hover(
  function () {
    $("#textDiv").text("New Text");
  },
  function () {
    $("#textDiv").text("Previous Text");
  }
);

You could use the jQuery Hover() event and just change the div containing your corresponding text :

$("#hoverArea").hover(
  function () {
    $("#textDiv").text("New Text");
  },
  function () {
    $("#textDiv").text("Previous Text");
  }
);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文