获取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"
);
}
})
|