jquery ui.sortable 带有工具提示
在页面上,我有一个带有缩略图的可排序列表。 当滚动图像时,我想要一个工具提示来显示更大的图像。 我找到了 qTip,但也许还有更好/更简单的东西?
如何将 imgPath var 从可排序连接到 qtip?
var imgPath = '<img src="002171/imm/001.jpg" />';
$("#sortable").sortable();
$("#sortable").disableSelection();
$('#sortable li img').qtip({
content: {
text: imgPath
}
});
<div id="demo">
<ul id="sortable">
<li><img src="002171/tn/001.jpg" /></li>
<li><img src="002171/tn/002.jpg" /></li>
<li><img src="002171/tn/003.jpg" /></li>
</ul>
</div>
On a page I have a sortable list with thumbnails.
When rolling over the images I wanted a tooltip to show a bigger image.
I found qTip, but maybe there is something better / easier?
How can I connect the imgPath var from the sortable to the qtip?
var imgPath = '<img src="002171/imm/001.jpg" />';
$("#sortable").sortable();
$("#sortable").disableSelection();
$('#sortable li img').qtip({
content: {
text: imgPath
}
});
<div id="demo">
<ul id="sortable">
<li><img src="002171/tn/001.jpg" /></li>
<li><img src="002171/tn/002.jpg" /></li>
<li><img src="002171/tn/003.jpg" /></li>
</ul>
</div>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我为您发布了演示。尽管我很喜欢 qTip,但弄清楚如何设置它以从当前 HTML 中获取内容并不容易。我花了 20 分钟搞乱它,直到我放弃。但是,好消息是我确实知道这个 工具提示脚本 有三个版本,其中一个是专门为图像预览而制作的。
因此,您需要稍微重新格式化您的 HTML。
中的
href
包含工具提示中显示的大图像,而![]()
包含缩略图。您还可以通过将文本/HTML 添加到链接的标题属性中,在工具提示中包含标题(请参阅下面代码中的第一张图片)。HTML
CSS
脚本
I posted a demo for you. As much as I like qTip, it isn't easy to figure out how to set it up to grab content from within the current HTML.. I spent 20 minutes messing with it until I gave up. But, good news is I do know that this tooltip script has three versions, and one is specifically made for image previews.
So you'll need to reformat your HTML a bit. the
href
in the<a>
contains the large image that shows up in the tooltip while the<img src>
contains the thumbnail. You can also include a caption in the tooltip by adding text/HTML into the title attribute of the link (see the first image in the code below).HTML
CSS
Script