Cam*_*ron 19 javascript jquery
如果我有一个网址:
HTTP://本地主机:53830 /组织/ 1216 /查看
我想以小写格式警告url路径的第一部分,例如'组织'
到目前为止,我有:
var first = $(location).attr('pathname');
first.indexOf(1);
first.replace('/', '');
first.toLowerCase();
alert(first);
Run Code Online (Sandbox Code Playgroud)
但它没有按预期工作.有人可以帮忙吗?谢谢
Sam*_*iew 33
location.pathname.split('/')[1]
Run Code Online (Sandbox Code Playgroud)
但我认为没有必要.toLowerCase().
Dog*_*ert 17
var first = $(location).attr('pathname');
first.indexOf(1);
first.toLowerCase();
first = first.split("/")[1];
alert(first);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
29350 次 |
| 最近记录: |