将 JQuery Lightbox() 函数与 Datalist 中的 HTML 链接元素链接
我正在 DataList 中实现此 JQuery Lightbox 插件:
如果链接位于 DataList 之外,我测试了此代码是否可以工作:
$('a[@rel*=lightbox]').lightBox();
但它似乎没有拾取 DataList 内具有“rel=lightbox”的链接。
所以我四处挖掘并尝试从这里吸取一些教训:
想出了这个,但似乎不起作用:
$('a.imageActivator').live("click", function() {
jQuery.lightBox();
});
出了什么问题?
I'm implementing this JQuery Lightbox plugin inside a DataList:
I tested this code to work if the link is outside the DataList:
$('a[@rel*=lightbox]').lightBox();
But it does not seem to pick up the links inside the DataList which has "rel=lightbox".
So I went digigng around and try to take some lessons from here:
Came up with this but does not seem to work:
$('a.imageActivator').live("click", function() {
jQuery.lightBox();
});
What went wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我认为您需要在点击函数中包含
return false;
。I think you need to include a
return false;
in your click function.我尝试了 JQuery Lightbox 和 JQuery Fancybox。
JQuery Lightbox (如上所述)似乎存在 lightBox() 无法绑定/链接到 Click 事件的问题。
JQuery Fancybox 提出了必须单击两次才能激活图像的问题。而且它也不显示第二张图像(但再次显示相同的第一张图像)。
所以最后,我打破了常规,使用了 Lightbox2:
问题是 $ 与全局声明的 JQuery 的 $ 冲突。因此,在做了一些研究之后,这是我对此的建议。
按如下方式对脚本进行排序:
JQuery 脚本必须具有“jQuery.noConflict();”作为第一行。页面上使用的任何 JQuery $ 符号都必须更改为“jQuery”。例如:
这使我能够使用与 jQuery 脚本共存的 Lightbox。
I tried JQuery Lightbox and JQuery Fancybox.
JQuery Lightbox (as above) seem to present the issue that the lightBox() cannot be bound/linked to the Click event.
JQuery Fancybox presented the issue of having to click TWICE to activate the image. And it also doesn't show the 2nd image (but show the same 1st image again).
So in the end, I went against the norm and used Lightbox2 instead:
The issue with this is the $ conflicts with JQuery's $ which is declared globally. So here is my tip around this after doing some research.
Sequence the scripts as follow:
JQuery script will have to have "jQuery.noConflict();" as the first line. Any JQuery $ sign used on the page will have to be changed to "jQuery". For Example:
That was what allowed me to use a Lighbox that works which co-exists with jQuery scripts.