如何让 jQuery 在鼠标悬停时执行一件事,在单击时执行另一件事?
我正在构建一个照片库,它有两种查看图像的方式,第一种是鼠标悬停,以便显示工具提示预览图像,第二种是单击将查看者带到带有预览图像和更多信息的新页面关于图像,就像您在 iStock Photo 上看到的一样:http: //www.istockphoto.com/stock-photo-2159036-hot-air-balloons.php
您可以在这里查看我的开发页面:http://ee.rouviere.com/%5Ehtml/photography/index.html
目前我正在使用 fancybox,它可以很好地在以下情况下显示预览图像:您单击缩略图。但是,我想更改此设置,以便当您将鼠标悬停在缩略图上时它会出现。与此页面上的操作非常相似:http://www.webinventif。 fr/wp-content/uploads/projets/tooltip/02/ 事实上,如果当您单击图像时它会将您带到图像详细信息页面而不是仅在新窗口中加载图像,那么这将是完美的。
目前 fancybox jQuery 代码是这样的:
<script type="text/javascript">
jQuery(document).ready(function() {
$("a.view-preview").fancybox({
'titleShow' : false,
'transitionIn' : 'elastic',
'transitionOut' : 'elastic'
});
});
</script>
我将不胜感激任何我能得到的帮助。谢谢!
I am building a photo gallery that has two ways of viewing images, the first is on mouse over so that it brings up a tooltip preview image and the second is on click to take the viewer to a new page with the preview image and more information about the image, much like you would have on iStock Photo: http://www.istockphoto.com/stock-photo-2159036-hot-air-balloons.php
You can view my development page here: http://ee.rouviere.com/%5Ehtml/photography/index.html
Currently I am using fancybox which works nicely to bring up the preview image when you click on the thumbnail. However, I would like to change this so that it comes up when you mouse over the thumbnail. Much like it does on this page: http://www.webinventif.fr/wp-content/uploads/projets/tooltip/02/ In fact this would be perfect if when you click on the image it takes you to an image detail page instead of just loading the image in a new window.
Currently the fancybox jQuery code is like this:
<script type="text/javascript">
jQuery(document).ready(function() {
$("a.view-preview").fancybox({
'titleShow' : false,
'transitionIn' : 'elastic',
'transitionOut' : 'elastic'
});
});
</script>
I would appreciate any help I can get on this. Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
听起来您想要的是工具提示而不是灯箱(fancybox)。尝试使用工具提示插件,例如 jQueryTools Tooltip。
更新:我更新了插件代码以使用以下 HTML 布局。将
标记中的
#
替换为用户单击图像时想要转到的页面。另外,这里有一个演示。这是更新后的脚本:
It sounds like what you want is a tooltip instead of a lightbox (fancybox). Try using a tooltip plugin, something like jQueryTools Tooltip.
Update: I updated the plugin code to work with the following HTML layout. Replace the
#
in the<a>
tag with the page you want to go to when the user clicks on the image. Also, here is a demo.This is the updated script: