gpt4 book ai didi

javascript - "/users/#something here"的 window.location.pathname

转载 作者:行者123 更新时间:2023-12-02 13:45:19 26 4
gpt4 key购买 nike

所以我有诸如 "/users/2""/users/4""/users/25" 的路径等等,我需要设置一个 if 语句,例如:

if(window.location.pathname == "/users/?????") {};

捕获所有这些路径。

最佳答案

您可以查看indexOf '/users/'

var pathName = window.location.pathname;

if (pathName.indexOf('/users/') === 0) {

}

关于javascript - "/users/#something here"的 window.location.pathname,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41449244/

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