Jquery:使用window.location获取某个url路径

DoY*_*ite 6 jquery jquery-selectors window.location

我们的url路径名是

www.nicadpower.com/index.com
Run Code Online (Sandbox Code Playgroud)

但我们只希望以后拿到路径www.nicadpower.com这是

index.com
Run Code Online (Sandbox Code Playgroud)

我们如何使用window.location和jquery获取index.com

Ord*_*Ord 9

我想你想要的

window.location.pathname
Run Code Online (Sandbox Code Playgroud)

这会给你/index.com

要摆脱领先/,您可以简单地使用子字符串:

window.location.pathname.substring(1);
Run Code Online (Sandbox Code Playgroud)