Forum Moderators: open
<link rel="stylesheet" type="text/css" href="style_images.css"><!-- MY CSS -->
<script type="text/javascript" src="assets/big_images.js"></script>
<div class="content_wrap">
<div id="bodycopy97681"><h1 style="font-size:120%">See the range on offer</h1><br>
<div class="car_model_description">
<div class="compare_button">
<a href=#><img src="assets/compareBTN.png" alt=""></a>
</div>
<h3 id="caption_title"></h3>
<p class="caption" id="caption">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec imperdiet nisi gravida lacus tempor semper. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae</p>
</div>
<div class="image_container">
<img src="assets/placeholder.jpg" alt=" placeholder car" id="placeholder_image" width="940" height="366">
<img src="assets/image_1.png" alt="car1" class="image_invisible" width="940" height="366">
<img src="assets/image_2.png" alt="car2" class="image_invisible" width="940" height="366">
...
</div><!-- END OF image_container -->
<div class="thumbnails">
<div class="thumbnails_row">
<a onclick="changeImage(this,'assets/image_1.png')">
<img src="assets/thumb1.jpg" alt="">
<span>Car1</span>
<h3>Car1</h3>
<p class="caption">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam urna tellus, scelerisque dictum vulputate et, posuere scelerisque mi. Morbi eu purus libero.</p>
</a>
<a onclick="changeImage(this,'image_2.png')">
<img src="assets/thumb2.jpg" alt="">
<span>car2</span>
<h3>car2</h3>
<p class="caption">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam urna tellus, scelerisque dictum vulputate et, posuere scelerisque mi. Morbi eu purus libero.</p>
</a>
...
<div class="clear"></div>
</div><!-- END OF ROW -->
</div><!-- END OF THUMBNAILS --> .image_container{
background:url('ajax-loader-black.gif') no-repeat 50% 50%;
width:940px;
border:1px solid blue;
margin:0 auto;
}
.image_invisible{display:none}
.image_visible{display:block}
.clear{clear:both;}
.thumbnails{
width:820px;
/*border:1px solid red;*/
margin:10px auto;
}
.car_model_description p{
font-size:1.2em;
text-align:left;
/*padding-bottom:16px;*/
width:600px;
}
.car_model_description h3{
text-align:left;
}
.car_model_description{
position:relative;
padding-right:215px;
width:725px;
min-height:70px;
}
.compare_button {
position:absolute;
width:215px;
top:50%;
right:0;
}
.thumbnails_row{
/*border:1px solid green;*/
width:940px;
margin-top:10px;
}
.thumbnails_row img{
cursor:pointer;
}
.thumbnails_row h3, .thumbnails_row p {
display:none;
}
.thumbnails_row a span{
display:block;
text-align:center;
}
.thumbnails_row a{
display:inline-block;
margin-right:25px;
} function changeImage(calledFrom, big_image){
var newImage = $('#placeholder_image');
var newTitle = $(calledFrom).find('h3').html();
var newText = $(calledFrom).find('p').html();
newImage.attr('src', big_image);
$('.car_model_description')
.find('h3').html(newTitle).end()
.find('p').html(newText);
}
function resetThumbnails(){
$('.thumbnails a').each(function(){
$(this).stop(true, true).fadeTo(500,1);
});
}
$(document).ready(function(){
$('.thumbnails')
.mouseleave(function(){
resetThumbnails();
})
.find('a').hover(function(){
hoverThumbnail(this);
});
});
function hoverThumbnail(calledFrom){
var $calledFrom = $(calledFrom);
$('.thumbnails a').each(function(){
if($(this).get(0) == $calledFrom.get(0)){
$(this).fadeTo(0,1);
}
else {
$(this).fadeTo(0,0.5);
}
});
} $(document).ready(function(){
$('.thumbnails')
.mouseleave(function(){
resetThumbnails();
})
.find('a').hover(function(){
hoverThumbnail(this);
});
});
we select the thumbnails div and on mouseleave we run the resetFunction, fine. The we find the a tag and on hover we run the hoverThumbnail function passing a parameter function hoverThumbnail(calledFrom){
var $calledFrom = $(calledFrom);
$('.thumbnails a').each(function(){
if($(this).get(0) == $calledFrom.get(0)){
$(this).fadeTo(0,1);
}
else {
$(this).fadeTo(0,0.5);
}
});
} if($(this).get(0) == $calledFrom.get(0)){
$(this).fadeTo(0,1);
}
else {
$(this).fadeTo(0,0.5);
}