将自定义 html 添加到 lightbox2
我有一个用 lightbox 2 制作的画廊,通常用缩略图等制作。现在我需要通过 JS 添加一些 HTML 到 lightbox 2 的 div 中。我该怎么做?
首先我想,只要做一个函数并用 onclick 调用它,但是 lightbox 还没有准备好,所以我必须等待它准备好,我该怎么做? Lightbox 使用原型框架。是否有可能以这种方式,像听众一样?
谢谢 :)
I have a gallery made with lightbox 2 made in a normal matter with thumbnails etc. Now I need to add some HTML via JS into a div of lightbox 2. How do I do that?
First I thought, just do a function and call it with onclick, but lightbox isn't ready then, so I have to wait for it to be ready, how do I do that? Lightbox uses the prototype framework. Is it possible in this way, something like a listener?
Thanks :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Lightbox2 没有任何公共活动。最好的选择是使用包含您可以订阅的公共事件的脚本。我推荐 Fancybox 或 彩盒。
使用 Fancybox,您只需在 Fancybox 打开完成时调用的
onComplete
函数中添加代码即可。请注意,这两个都使用 jQuery,但只要您使用 就不会有问题noConflict()。
Lightbox2 doesn't have any public event for that. Your best bet is to use a script that has public events that you can subscribe to. I would recommend either Fancybox or Colorbox.
With Fancybox you would just need to add the code inside the
onComplete
function that is called when the Fancybox is finished opening.Note that both of these use jQuery, but that shouldn't be a problem as long as you use noConflict().