Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

putting a variable into a css button's href attribute

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 :)

like image 688
Amira Manai Avatar asked May 25 '26 16:05

Amira Manai


1 Answers

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>
like image 110
Joseph Avatar answered May 28 '26 06:05

Joseph



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!