gpt4 book ai didi

javascript - jQuery - 选择除特定子项之外的类

转载 作者:行者123 更新时间:2023-11-30 13:20:26 25 4
gpt4 key购买 nike

我正在使用此处的照片 slider 代码:http://tympanus.net/codrops/2010/10/07/slider-gallery/并尝试对其进行修改,以便图片下方的链接在新窗口中加载。

例如:

<div class="content">
<div><a href="#"><img src="http://imageurl" alt="largeimageurl" /></a></div>
<div class="caption"><a target="_blank" href="image.php?id=someid&svc=somesvc" rel="nofollow">More Info</a></div>
</div>

我已经用 javascript 文件尝试了各种不同的东西,目前是这样写的:

$fp_content_wrapper.find('.content').bind('click',function(e){
var $current = $(this);
//track the current one
current = $current.index();
//center and show this image
//the second parameter set to true means we want to
//display the picture after the image is centered on the screen
centerImage($current,true,600);
e.preventDefault();
});

我需要做的是更改第一行,使其正常选择,但不对包含链接的标题 div 应用任何内容,以便它正常运行。

我知道在 SO 上也有类似的问题,但我已经尝试了大部分建议的问题。我对 JS 一点经验都没有,所以很容易是我做错了。

感谢任何帮助!

最佳答案

试试这个:

$fp_content_wrapper.find('.content>*:not(.caption)').bind('click',function(e) .....

发生的事情是您选择了内容标签,而不是您想要选择其中的内容,除了具有 .csption 类的任何内容。'>' 表示正下方的元素,'*' 表示全选。因此,它的意思是“选择 .content 正下方不是 .caption 类的所有内容”。

如果您继续使用 jquery,那么研究选择器是值得的。

祝你好运

关于javascript - jQuery - 选择除特定子项之外的类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10381873/

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