Reputation: 2599
I want to affect a variable containing url to a css button's href attribute i tried location.href but it didn't work .
here's my button description :
<div>
<p><a id="gameNextLevel" class="button" href="">Next</a></p>
</div>
Here's my JSF related code :
var uiNextLevel = $("gameNextLevel");
matchingGame.savingObject.currentLevel="game6.html";
uiNextLevel.click(function(e) {
e.preventDefault();
// location.href = "login.html";
location.href = matchingGame.savingObject.currentLevel;
});
Any idea please , Thank you in advance :)
Upvotes: 3
Views: 548
Reputation: 10992
uiNextLevel.click(function(e) {
e.preventDefault();
$(this).attr("href") = matchingGame.savingObject.currentLevel;
});
Upvotes: 2
Reputation: 119867
You missed the hash #
in the selector, which means id
var uiNextLevel = $("#gameNextLevel");
also, for "dead links", use a hash #
also in the href
.
<a id="gameNextLevel" class="button" href="#">Next</a>
Upvotes: 3