Matt Coady
Matt Coady

Reputation: 3856

Change a portion of a url

a have a url that is as follows

<a href="www.mysite.com/foo/content">Link</a>

How do I remove the "/foo" using jquery so it'll end up like this.

<a href="www.mysite.com/content">Link</a>

Upvotes: 0

Views: 37

Answers (1)

Ohgodwhy
Ohgodwhy

Reputation: 50787

$('a').prop('href', function(i,href){
    return href.replace('/foo', '');
});

Upvotes: 4

Related Questions