Reputation: 5361
So I've learned that I can use a button to link someone to another page like this:
$("#something").append("<br><center><input type='button' value='Go' onclick='location.href=\"http://www.google.com\"'></center>");
But let's say I wanted to use a variable as the address, I'm not sure how to do that. What I'm trying to do is something like this:
var url = "http://www.google.com";
$("#something").append("<br><center><input type='button' value='Go' onclick='location.href=url'></center>");
Can someone please correct my error? Thanks
Upvotes: 2
Views: 95