獲取URL后面錨點(diǎn)ID的方法依然很簡(jiǎn)單,一行代碼搞定。
var thisId = window.location.hash;
如何運(yùn)用獲取到的ID:
例如:對(duì)URL后面錨點(diǎn)的ID添加樣式(.uw3c):
$(function(){
var thisId = window.location.hash;
if(thisId != "" && thisId != undefined){
$(thisId).addClass("uw3c");
}
})
!評(píng)論內(nèi)容需包含中文