如何使用 jQuery 或 CSS 实现这种效果?

发布于 2024-09-01 22:03:32 字数 200 浏览 3 评论 0原文

是否可以通过点击切换 HTML?

我有一个带有大图像的索引页。图片下方有四个链接。当光标滚动到链接上时,我希望出现一个小工具提示。如果用户单击链接,我希望大图像发生变化,并在其上方显示一些额外的 HTML(只是一个小内容框)。

我想我已经使用 jQuery 找到了工具提示,但我不确定如何更改图像并在其上添加一个小内容框。

预先感谢大家。

Is it possible to switch HTML on click?

I have an index page with a large image. Under the image there are four links. When the cursor rolls over a link I would like a small tooltip to appear. If the user clicks the link I want the large image to change and some extra HTML to appear over it (just a small content box).

I think I have figured out the tooltip using jQuery but I'm not sure how to change the image and add a small content box over it.

Thanks in advance everyone.

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

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

发布评论

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

评论(3

云朵有点甜 2024-09-08 22:03:33

在我看来,您可能需要一个内容滑块...查看 这个25 个不同的列表

It sounds to me like you might want a content slider... check out this list of 25 different ones.

恏ㄋ傷疤忘ㄋ疼 2024-09-08 22:03:32

考虑这个片段:

$("#someLinkID").click(function() {
    $("#someImageID").attr("src","newimage.jpg");
    $("#someContentDiv").show();
});

语法可能不对,我已经几个月没有使用 jQuery了,但是你明白了。基本上,您将一个点击处理程序附加到链接,当处理程序被触发时,您可以动态地将图像标签的 src 属性更改为您想要的任何图像,同时您可以显示您已定位的 div提前将图像的可见性设置为隐藏。

Consider this snippet:

$("#someLinkID").click(function() {
    $("#someImageID").attr("src","newimage.jpg");
    $("#someContentDiv").show();
});

The syntax might be off, i haven't used jQuery in a few months, but you get the idea. Basically, you attach a click handler to the link, and when the handler is fired, you can dynamically change the src attribute of the image tag to whatever image you want, and at the same time you can show a div that you have positioned over the image ahead of time with its visibility set to hidden.

掌心的温暖 2024-09-08 22:03:32

Tabtastic 是一个很好的、可访问的、优雅的降级实现。

Tabtastic is a good, accessible, gracefully degrading implementation of this.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文