Код: Выделить всё
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;
});
- сохраняет текущую позицию (числовую) элемента, чтобы отслеживать подсчет
Код: Выделить всё
currPosition - — числовое значение общего количества связанных изображений.
Код: Выделить всё
totalItems
Подробнее здесь: https://stackoverflow.com/questions/383 ... a-variable
Мобильная версия