在幻灯片放映中使用 .delegate 函数
我有一个为我的页面运行幻灯片的脚本。我正在尝试使用 .delegate()
插入幻灯片中显示的一组新图像(包括其缩略图)。我使用 .load()
函数加载外部
来替换活动页面中的一些 HTML。我还有带有 ID 的按钮(#kick1
、#kwick2
等),用于确定加载哪组幻灯片。 jQuery("#kwick2").click(function () {
jQuery("body").delegate('#slideshow', 'click', function() {
jQuery('#slideshow').load('/design.html #design');
)};
)};
很确定语法完全错误。有人可以帮助我吗?
#slideshow
div
是我创建的,用于直接包含其他一些 div
受幻灯片脚本的影响。 div
ID #slideshow
内为
、
;
和
。当您单击 KWICK 按钮时,这些内容将被直接替换,它们几乎都是不言自明的,图像拇指具有图像链接和带有图像链接的无序列表。
I have a script that runs a slideshow for my page. I'm trying to use .delegate()
to insert a new set of images shown within the slideshow including its thumbnails. I'm using a .load()
function to load an external <div>
to replace some HTML within the active page. I also have buttons with IDs, (#kick1
, #kwick2
, etc.) that determine what set of slide show is loaded.
jQuery("#kwick2").click(function () {
jQuery("body").delegate('#slideshow', 'click', function() {
jQuery('#slideshow').load('/design.html #design');
)};
)};
Pretty sure the syntax is all wrong. Can someone help me?
The #slideshow
div
is something I created to contain some other div
s directly
effected by the slideshow script. Within div
ID #slideshow
are
<div class="main_image">
, <div class="desc">
and <div class="image_thumb">
.
These are being replaced directly when you click a KWICK button, they are all pretty much self explanatory, image thumb has and unordered list with image links.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您不应在每次单击按钮时重新委托。你做错了。
相反,你应该拥有类似:
或类似的东西..
并且不,我没有测试此代码。它是为了解释这个概念而写的,而不是用来填鸭式的。
You should not re-deligate every time you click the button. You are doing the wrong.
Instead what you should have is something like:
Or something similar to this ..
And no , i did not test this code. It is written to explain the concept, not to spoon-feed people.
不确定我是否很好地理解了这个问题,无论如何,你必须指定你要委托的事件
委托
not sure if i have understood the question well, anyway you have to specify what event you are delegating
delegate