【发布时间】:2012-05-10 01:06:00
【问题描述】:
我正在使用此处的照片滑块代码: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 经验,所以很容易是我做错了。
感谢任何帮助!
【问题讨论】:
-
标题 div 的 html 代码是什么?如果您的意思是 id,您可以使用
$fp_content_wrapper.find('.content').not('#caption').bind('click',function(e){或将#更改为.(如果它是一个类) -
代码在问题的第一个代码块中,嵌套在内容 div 中。我尝试将标题 div 放在此之外,但它会导致更多的样式工作。最终可能会更容易做到这一点。
-
你说的太对了,我怎么没看到!
-
我仍然感谢您的帮助 :-)
-
我已经为你添加了答案。请让我知道这可不可以帮你。干杯
标签: javascript jquery select except