gpt4 book ai didi

jQuery:将 live() 与 every() 一起使用

转载 作者:行者123 更新时间:2023-12-03 22:33:31 26 4
gpt4 key购买 nike

我这里有这个功能:

$("a.fancybox_vid").each(function(){
$(this).fancybox({
titleShow : false,
width: 640,
height: 395,
autoDimensions: false,
overlayOpacity: 0.6,
href: "misc/mc.php?v="+$(this).attr('id')
});
});

现在附加了类 .fancybox_vid 的链接,然后这将不起作用。只要它从一开始就存在。我怎样才能在这个each()中拥有live()。

最佳答案

如果您想要方法具有“类似实时”的功能,您可以使用 the livequery plugin :

$(function() {
$('a.fancybox').livequery(function() {
$(this).fancybox({
titleShow : false,
width: 640,
height: 395,
autoDimensions: false,
overlayOpacity: 0.6,
href: "misc/mc.php?v="+$(this).attr('id')
});
});
});

...尽管在新创建的元素上调用 fancybox 插件会更好(开销更少)。

关于jQuery:将 live() 与 every() 一起使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4483858/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com