To get the path name with url values ​​in jquery

This is an example URL.

http://stackoverflow.com/questions/ask?a=1&b=2

question : do I need to get the path name along with URL values ​​such as

/ questions / ask? a = 1 & b = 2
I need jQuery or javascript solution
+3
source share
1 answer
var url = document.createElement('a');
url.href = 'http://stackoverflow.com/questions/ask?a=1&b=2';
alert(url.pathname + url.search);

Demo: http://jsfiddle.net/karim79/8XYYj/

+3
source

Source: https://habr.com/ru/post/1778056/


All Articles