开发者

How to remove the first slash in my URL with JavaScript

开发者 https://www.devze.com 2023-02-06 23:35 出处:网络
i need to remove the first \"/\" in my url. As you can see my first value is correct, now i need to do the same to the second url.

i need to remove the first "/" in my url. As you can see my first value is correct, now i need to do the same to the second url. How can i delete th开发者_如何学Goe first "/"

option=com_content&view=article&id=2&Itemid=2     <    CORRECT
/option=com_content&view=article&id=2&Itemid=2     <   NOT GOOD FOR ME


Different way

var rawurl = "/option=com_content&view=article&id=2&Itemid=2";

rawurl = rawurl.substr(rawurl.indexOf('/') + 1);


Try this -

var str = "/option=com_content&view=article&id=2&Itemid=2";

str.replace(/\//, "");

Note: In this answer i have assumed you to save this part of url in variable str first.

0

精彩评论

暂无评论...
验证码 换一张
取 消