To start, you can locate all of my code right here.
http://jsfiddle.net/yfukm8kh/1/
The issue I'm encountering pertains to the following section.
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);
}
};
The goal for this function is to modify the background-image
of the div id=lightbox
to one specified in the provided array
.
However, when clicking on the sidebar, it seems that the entire <div id=lightbox>
is being removed as though the click was directed at the div
itself rather than the sidebar. Nonetheless, upon inserting an alert
within the function
, it confirms that the event was triggered and some code within the function
executed.
I suspect that clicking on the sidebar triggers two events - one for changing the background-image
and another for removing the lightbox
element again.
Is there a way to prevent the underlying div
from responding to the click?
Furthermore, please feel free to correct me if I've misused any terms or violated proper posting etiquette. As a newcomer, any guidance from seasoned users would be greatly appreciated.
Thank you very much.