gpt4 book ai didi

参数中的 jQuery、Colorbox、jQuery 语法

转载 作者:行者123 更新时间:2023-12-01 03:51:20 25 4
gpt4 key购买 nike

我想执行以下操作,但它不起作用。我再次确信它应该很简单,但我无法编译它。

$(".villa-caller").colorbox({
innerWidth: "850px",
innerHeight: "500px",
inline: true,
href: "#"+$(this).attr("rel")+"",
onClosed:function(){colorbox_closed();}
});

href 参数上,我使用 jQuery 语法从单击的元素获取 rel 属性的值。

感谢您的帮助

最佳答案

我认为这里的问题是由于 this 的范围造成的。请尝试以下操作:

$(".villa-caller").each(function() {
$(this).colorbox({
innerWidth: "850px",
innerHeight: "500px",
inline: true,
href: "#" + $(this).attr("rel") + "",
onClosed:function(){ colorbox_closed(); }
});
});

这应该确保 this 是您要初始化 colourbox.villa-caller 元素。

关于参数中的 jQuery、Colorbox、jQuery 语法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8270379/

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