Difference between revisions of "Template:SJTU-Software/humanPracticeJs"
Ricky chen (Talk | contribs) |
Ricky chen (Talk | contribs) |
||
Line 16: | Line 16: | ||
} | } | ||
var scrollToA = function(){ | var scrollToA = function(){ | ||
− | var target = $(this).attr("href"); | + | var target = $(this).attr("xlink:href"); |
target = $(target); | target = $(target); | ||
if (target.length){ | if (target.length){ |
Revision as of 23:48, 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("xlink:href"); target = $(target); if (target.length){ $('html,body').animate({ scrollTop: target.offset().top },600) } }