Reputation: 13
Im wondering how do I replace a hashtag with a slash in the URL with Javascript or Jquery.
Example:
www.mysite.com/service#new
To:
www.mysite.com/service/new
Is this possible? I really can´t figure it out.
Greetings!
Upvotes: 1
Views: 1253
Reputation: 149020
Why not just do this:
var url = "www.mysite.com/service#new";
url = url.replace('#', '/');
Or if you're trying to manipulate DOM elements directly, something like this should work:
$('a').each(function(i, e) {
e.href = e.href.replace('#', '/');
});
Upvotes: 2