[英]How to remove the url paramters having %20 on click in jquery
i have any issue where i want to remove url parameters when on click the div, while some parameters are in words and some are numbers that containing %20, i am not able to remove those ones, can you please help me.我有任何问题,我想在单击 div 时删除 url 参数,而有些参数是文字,有些是包含 %20 的数字,我无法删除那些,你能帮帮我吗?
my url is https://www.schooleducation.com/onlin/courses/?filter=8%27%20-%2015%27我的 url 是https://www.schooleducation.com/onlin/courses/?filter=8%27%20-%2015%27
i want to remove 8' - 15' url parameter value from the url when onlclick here is my code我想从 url 中删除 8' - 15' url 参数值 onlclick here is my code
$('.fileter-container').once('filter-click').on('click', function () {
var key = $(this).data('key');
$(this).remove();
var url = 'https://www.schooleducation.com/onlin/courses/?filter=8%27%20-%2015%27'
var re = new RegExp("&filter=\\d+");
var newurl= url.replace(key, '');
// var newurl = url.split('?')[0];
location.replace(newurl);
});
Try decoding the URL string before manipulating it.在操作之前尝试解码 URL 字符串。
See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/decodeURIComponent请参阅https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/decodeURIComponent
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.