如何獲取判斷URL后面錨點
所屬欄目: 網(wǎng)站開發(fā) | 更新時間:2016-10-23 | 閱讀:5324 次
獲取URL后面錨點ID的方法依然很簡單,一行代碼搞定。
var thisId = window.location.hash;
如何運用獲取到的ID:
例如:對URL后面錨點的ID添加樣式(.uw3c):
$(function(){
var thisId = window.location.hash;
if(thisId != "" && thisId != undefined){
$(thisId).addClass("uw3c");
}
})