location.hash 屬性:設置或取得當前URL中的錨

範例:

▼設置錨點 (連結按了網頁不會重新整理)

<a href="#story">


▼js判斷錨點內容做動作

if(location.hash == "#story" || location.hash == "#character" || location.hash == "#background"){
 $(".story_totalnav").addClass("active");
 $(".navigation_2nd").fadeIn(500)
}else{
 $(".story_totalnav").removeClass("active");
 $(".navigation_2nd").fadeOut(500)
}

if(location.hash == "#ost"){
 $(".ost_area").addClass("active")
}else{
 $(".ost_area").removeClass("active")
}

發表迴響