gpt4 book ai didi

javascript - 如何从 URL 中获取片段标识符(哈希 # 后的值)?

转载 作者:IT老高 更新时间:2023-10-28 13:14:48 25 4
gpt4 key购买 nike

例子:

www.site.com/index.php#hello

使用 jQuery,我想将值 hello 放入变量中:

var type = …

最佳答案

不需要 jQuery

var type = window.location.hash.substr(1);

自从 String.prototype.substr已弃用 substring而是。

var type = window.location.hash.substring(1);

关于javascript - 如何从 URL 中获取片段标识符(哈希 # 后的值)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11662693/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com