I'm working on a simple if/else statement to show a next or previous link, but somehow my checkup don't work. Here's the code
var newPosition = currPosition;
$(".imageNavLink").click(function(event){
event.preventDefault();
newPosition = (this.rel == "next") ? newPosition + 1 : newPosition - 1;
var newImageLink = this.title;
var clickAction = this.rel;
var newImage = new Image();
$(newImage).load(function(){
newWidth = this.width, newHeight = this.height+35;
if(newPosition == totalItems){
[.. Show 'previous' link ..]
}else if(newPosition == 1){
[.. Show 'next' link ..]
}else{
[.. Show 'previous' and 'next' link ..]
}
});
newImage.src = this.title;
});
currPositionholds the current position (numeric) of the element to keep on track with the counttotalItemsis the numeric value of the total associated images
If i click on the first image i constantly see the previous link, when i start with the second image i constantly see both links and when i start with the last image i constantly see the previous link..