Hi everyone,
I need some help in jQuery. What I'm trying to do is to create some sort of a small picture gallery. In this gallery I've got a couple of small pics and one big pic. By clicking a small picture I want jQuery to load and replace the big picture.
Here's a little try which does not work! But probably someone could tell me why.
$(function(){
$("a.smallpics").click(function(e){
$(".bigpic")
.load(function () {
$(this).hide();
$('#loader')
.append(this);
.removeClass('loading')
$(this).fadeIn();
});
.attr('src', this.href);
e.preventDefault();
});
});
and the html
<a href="pic1_big.jpg" class="smallpics" /><img src="pic1_small.jpg" style="width: 20px; height: 20px" /></a>
<a href="pic2_big.jpg" class="smallpics" /><img src="pic2_small.jpg" style="width: 20px; height: 20px" /></a>
<a href="pic3_big.jpg" class="smallpics" /><img src="pic3_small.jpg" style="width: 20px; height: 20px" /></a>
<div id="loader" class="loading" /><img src="pic3_big.jpg" class="bigpic" /></div>
So in the best case the script would cover the big picture with a grey half transparent layer, start a spinner and after loading fading the picture in. (Spinner is in background of class 'loading')
Thanks for your help.