好吧,所以我刚刚学会了如何使用jquery切换目标div的图像源,但生成的图像加载了一个断开的链接。有一段时间,我甚至没有意识到如何尝试这样做。脚本实际上改变了目标div的图像源的事实是我所追求的,但我不知道它为什么会返回一个破碎的图像。缩略图栏中的一个图像是源内容div中的原始图像,但它也显示为中断。处理这些变化的代码是来自教程的内容,几乎是逐字的。Jquery'gallery'interactive results
我已经完成了对这个问题的快速搜索,所有我能找到的似乎都是无关的;我还没有学习任何PHP,所以这可能是一个问题。
HTML:
<table id="thumb_row">
<td><div class="thumb"><img src="../../../Documents/Blacktip-Reef-Shark.jpg" /></div> </td>
<td><div class="thumb"><img src="../about_clicked.png"/></div></td>
<td><div class="thumb wide_thumb"><img src="../Web_Teaser_Images/Hyp_1.jpg"></div></td>
<div id= "content_bar"><img src="../Web_Teaser_Images/Hyp_1.jpg"/></div>
CSS:
.thumb{ position: relative;
clear:both;
background-color:#747474;
z-index:201;
height: 120px;
width: 120px;
margin: 5px 5px 5px 5px;
opacity: 0;
overflow:hidden;
}
.thumb img{width: auto;
height: 120px;
margin: 0px 0px 0px 0px;
}
.wide_thumb img{width: auto;
height: 120px;
margin: 0px 0px 0px -100px;
}
#thumb_row {clear:both;
margin:665px 0px 0px 0px;
position: absolute;
z-index: 100;
background-color: none;
height: auto;
width: 100%;
float: right;
的Jquery:
$(".thumb").click(function(){
var image = $(this).attr('rel');
$('#content_bar').fadeOut("fast");
/*THIS IS THE LINE THAT SHOULD SWAP IMG SRC*/
$('#content_bar').html('<img src="'+image+'"/>');
$('#content_bar').fadeIn("fast");
});
在应交换IMG SRC行了,你正在使用的变量'image',但它没有任何价值(它是空的)。您正试图从缩略图(?!)中读取名为“'的属性。请注意把你的例子从哪里拿出来,所以我们可以指出你出错的地方? – marlenunez
链接如下:http://designsnack.com/blog/tutorials/how-to-create-a-simple-jquery-gallery/ –
同样,我仍然不熟悉背后的方法。我之前编辑过我的帖子,因为我在var属性中忽略了'rel',但对代码的更改不能解决问题。我也尝试使用作者使用的脚本来源,但这似乎没有什么区别。 –