gpt4 book ai didi

jQUERY获取url的父文件夹

转载 作者:行者123 更新时间:2023-12-01 04:45:06 25 4
gpt4 key购买 nike

我想使用 Ajax 加载 xml 文件。该文件位于根目录的另一个文件夹中。

  1. 如何使用 jQuery 获取根目录路径?
  2. 如何使用 jQuery 移动到当前路径的父目录?

最佳答案

这将返回根/主机名:

window.location.hostname

这将返回父文件夹的路径。

var string1 = "../example/index.html";
var string2 = string1.replace(string1.split("/").pop(),"");

string2=../example/

关于jQUERY获取url的父文件夹,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30861300/

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