[英]How can I remove the specific character from href link?
My link is https://mytestsite.com/search/label/interesting?m=1
我的链接是https://mytestsite.com/search/label/interesting?m=1
How can I remove the ?m=1
from end of link?如何从链接末尾删除?m=1
?
You can simply do like this你可以简单地这样做
var address = "https://mytestsite.com/search/label/interesting?m=1"; var pieces = address.split('?')[0]; // to show address after being sliced alert(pieces);
You can simply split the url at ?
您可以简单地将 url 拆分为?
character.特点。
var link = 'https://mytestsite.com/search/label/interesting?m=1';
var arr = link.split('?');
console.log(arr[0]);
In arr[0]
you will get result - https://mytestsite.com/search/label/interesting
在arr[0]
你会得到结果 - https://mytestsite.com/search/label/interesting
var str = "https://mytestsite.com/search/label/interesting?m=1";
str = str.slice(0, -4);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.