我在jquery
上有基本知识,因此有人可以指导我,如果此功能pre button
将在默认值中 display:none
,而 next button
也可以在最后一个
JS:
$('div.section').first();
$('a.display').on('click', function(e) {
e.preventDefault();
var t = $(this).text(),
that = $(this);
if (t === 'next' && $('.current').next('div.section').length > 0) {
var $next = $('.current').next('.section');
var top = $next.offset().top;
$('.current').removeClass('current');
$(function () {
$next.addClass('current');
$('html, body').animate({scrollTop: $('.current').offset().top }, 'slow');
});
} else if (t === 'prev' && $('.current').prev('div.section').length > 0) {
var $prev = $('.current').prev('.section');
var top = $prev.offset().top;
$('.current').removeClass('current');
$(function () {
$prev.addClass('current');
$('html, body').animate({scrollTop: $('.current').offset().top }, 'slow');
});
}
});
这是小提琴
这应该为您做。让我知道它是如何工作的。
function hideShowLinks() {
$('.section').each(function (k, v) {
var self = $(this);
if (self.hasClass('current')) {
if (k == 0) {
$('#display1').hide();
$('#display').show();
} else if (k == ($('.section').length - 1)) {
$('#display').hide();
$('#display1').show();
} else {
$('#display, #display1').show();
}
}
});
}
hideShowLinks();
$(window).scroll(function () {
hideShowLinks();
});
小提琴