Replace a URL using jQuery

The problem: I need to replace a url on one page, but that url was defined in the master page of an app.

The solution: Use the jQuery .attr (attribute) selector to find the matching href attribute I want to replace. Here’s the one line of code that does the trick:

[crayon lang=”javascript”]$(“a[href]=’’]”).attr(‘href’, ‘’ )[/crayon]

Result: Mind. Blown. Instant awesomeness without needing to rebuild the app.


Leave a Reply