Difference between revisions of "Template:SJTU-Software/humanPracticeJs"

(Created page with "$(document).ready(function(){ $(".fixed-nav").css("top",$(window).height()*0.3); $("html").niceScroll(); $('.ayrNav').click(changePage); $('.hpceNav').click(changePage...")
 
Line 4: Line 4:
 
$('.ayrNav').click(changePage);
 
$('.ayrNav').click(changePage);
 
$('.hpceNav').click(changePage);
 
$('.hpceNav').click(changePage);
 +
        $('.scrollNav').click(scrollToA);
 
});
 
});
 
var changePage = function(){
 
var changePage = function(){
Line 13: Line 14:
 
$("."+active).css("display","none");
 
$("."+active).css("display","none");
 
})
 
})
 +
}
 +
var scrollToA = function(){
 +
var target = $(this).attr("href");
 +
target = $(target);
 +
if (target.length){
 +
$('html,body').animate({
 +
scrollTop: target.offset().top
 +
},600)
 +
}
 
}
 
}

Revision as of 18:10, 13 September 2015

$(document).ready(function(){ $(".fixed-nav").css("top",$(window).height()*0.3); $("html").niceScroll(); $('.ayrNav').click(changePage); $('.hpceNav').click(changePage);

       $('.scrollNav').click(scrollToA);	

}); var changePage = function(){ var active = $(this).attr("id"); var bros = $(this).siblings(); $("."+active).css("display","inline"); bros.each(function(){ active = $(this).attr("id"); $("."+active).css("display","none"); }) } var scrollToA = function(){ var target = $(this).attr("href"); target = $(target); if (target.length){ $('html,body').animate({ scrollTop: target.offset().top },600) } }