All,
I’ve got the following code:
var site_url = 'http://localhost/website/';
jQuery("#cancel_song_choice").click(function(event){
cancel_url = site_url + "event-form";
window.location.href(cancel_url);
});
Then I have the following HTML:
<button id="cancel_song_choice">Cancel Search</button>
When I click on the button it just keeps redirecting me back to the page that I’m on instead of going to the cancel url that I specified. I alert the cancel_url and it shows me the right one. Any ideas what I’m doing wrong?
hrefis not a function, it’s a property. Use:window.location.href = cancel_url;:Check out
window.locationon MDN.