当您单击作品集时,顶部会打开以显示详细信息(标题、年份、角色、描述)以及照片。我已经能够让每个项目替换所有文本数据,但我似乎无法将图像加载到缩略图中。
我已经能够在网站上的所有图像中获得我正在寻找的最后一张图像,但没有显示每个项目的每张照片。
这是我正在使用的 HTML:
<section id="details">
<div class="pagewrapper">
<section id="main-img">
<article id="big-img">
<img src="" alt="big-img" />
</article>
<article class="small-img-container">
<a href="#"><img src="#" alt="smallimg" class="small-img" /></a>
</article>
</section>
<section id="description">
<h3></h3>
<h4></h4>
<h5></h5>
<p></p>
</section>
</div>
<div class="clear"></div>
</section>
<section id="portfolio">
<div class="pagewrapper">
<h2 class="sectionTitle">Portfolio</h2>
<div class="thumb">
<a class="small" href="#" title="David Lockwood Music" data-year="2010" data-role="Sole Wordpress Developer" data-description="David Lockwood is a musician and an educator based in New Hampshire who came to me needing a website for his musical career. I fully developed his site using Wordpress as a CMS, creating a custom template based on the design by Jeremiah Louf. Jeremiah and I worked together on the website's UX design."><img src="images_original/davidcover.png" alt="thumb" />
<div class="hide">
<a href="images/davidlockwood/homepage.png" ></a>
<a href="images/davidlockwood/blog.png"></a>
<a href="images/davidlockwood/shows.png"></a>
<a href="images/davidlockwood/bio.png"></a>
<a href="images/davidlockwood/photos.png"></a>
</div>
<h3>David Lockwood Music</h3>
<div class="clear"></div>
</a>
</div><!--thumb-->
这是jQuery:
$(document).ready(function(){
var proj = {};
$('.thumb a').click(function() {
$('#details').slideDown(1000);
$('.hide a').each(function() {
proj.img = $(this).attr("href");
$('.small-img-container img').attr('src',proj.img);
});
alert("the image is " + proj.img);//is it getting the image URLS?
proj.title = $(this).attr("title");
proj.year = $(this).attr("data-year");
proj.role = $(this).attr("data-role");
proj.description = $(this).attr("data-description");
$('#description h3').text(proj.title);
$('#description h4').text(proj.year);
$('#description h5').text(proj.role);
$('#description p').text(proj.description);
});
});
任何人都知道我如何仅获取特定项目的图像,将它们全部显示为缩略图,然后使这些缩略图可单击以查看更大的图像?
谢谢!