First of all my code can be found here in total.
http://jsfiddle.net/yfukm8kh/1/
The part I'm having problems with is the following.
var changePic = function (direction, id, array) {
var intID = parseInt(id);
var intDir = parseInt(direction);
if (intID > 0) {
intID = intID + intDir;
currentID = intID;
alert(array[intID].link);
$('#lightbox').css("background-image", array[intID].link);
} else if (intID == 0 && intDir == 1) {
intID = intID + intDir;
currentID = intID;
alert(array[intID].link);
$('#lightbox').css("background-image", array[intID].link);
}
};
What I want this function to do is changing the background-image of the div id=lightbox to one with the URL in the array I'm giving the function.
However when I click on the sidebars the whole <div id=lightbox>is removed again as if I had clicked on the div itself() and not on the sidebar. However if I put an alert inside the function it shows that the event was triggered and at least some code inside the function was executed.
I'm now assuming that when I click on the sidebar I'm triggering two events, the one that would change the background-image and one that removes the lightbox again.
Is there any way to prevent the underlying div from "listening" to the click?
Also, please correct me if I'm using any terms incorrectly or my posting etiquette is off. I'm new to all of this and would appreciate the input from experienced users.
Thanks a lot.