tags:

views:

278

answers:

2

Suppose it's in a.html.

How to change url to b.html with jQuery?

+5  A: 

I assume you want to change the target (href) of a <a> element using jQuery?

$("a#your_id").attr("href", "b.html"); // where `a#your_id` is your selector

Or, you want to change the current location in the browser (redirect someone to another page)?

window.location = "b.html"; // No jQuery required for this!
Isaac Waller
I believe the location property is on the window object.
David Andres
Oops - my Javascript's a bit rusty... thanks.
Isaac Waller
A: 

if your question is how to change existing href=a.html to href=b.html, then this should work ..

$('a[href=a.html]').attr('href', 'b.html');
Scott Evernden