獲取URL后面錨點ID:
1
|
var
thisId = window.location.hash;
|
如何運用獲取到的ID:
例如:對URL后面錨點的ID添加樣式(.active):
1 2 3 4 5 6 |
$(
function
(){
var
thisId = window.location.hash;
if
(thisId !=
""
&& thisId != undefined){
$(thisId).addClass(
"active"
);
}
})
|