From:
http://www.site.com/example/index.html
How can I get just:
http://www.site.com/example/
And storing it into a variable using Javascript and how using jQuery also. Thanks in advance.
The following seems to work
new URL(".", "http://example.com/folder/subfolder/file.js")
http://jsfiddle.net/mXpBx/
var s1 = "http://www.site.com/example/index.html";
var s2 = s1.replace(s1.split("/").pop(),"");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With