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 asp.net 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]=’http://mysite.com/old’]”).attr(‘href’, ‘http://mysite.com/new’ )[/crayon]

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

 

New day, new technology.

Goodbye old asp.net site, hello WordPress! Get ready for some awesomeness coming soon!

Just for fun, right click and view the source to see how much error checking is required just to get a standard WordPress site to run in Internet Explorer!

Pro tip: Don’t use Internet Explorer.