0

Hi guys,

I change my code from Javascript to jQuery and I believe I have everything allright, but my jQuery is not showing the value. Can you help me with it? I am adding the important snippets but if you need all my code here is it Click Here.

Thank you.

My original Javascript

    function guessesUsed(attemptsTaken) {
        var numGuessesLeft = document.getElementById("userAttempts");
        numGuessesLeft.innerHTML = attemptsTaken;
    }

HTML (Older version)
<div>You have guessed: <span id="userAttempts"></span> times</div>

jQuery version

        function guessesUsed(attemptsTaken) {
            var numGuessesLeft = $('#userAttempts').val();
            numGuessesLeft.innerHTML = attemptsTaken;
        } //End of function guessesUsed(attemptsTaken)

HTML New Version
<p id="guessesUsed">You have guessed: <span id="userAttempts"></span> times out six(6) chances.</p>
CSS for the jQuery version

.guessesLeft {
    font-weight:bold;
    color:#C00;
}

Edited by gcardonav: Added link to my code

2
Contributors
4
Replies
16
Views
2 Years
Discussion Span
Last Post by gcardonav
0

I used your suggestion and now code is running smooth again. Thanks. I am not sure why my fucntion became obsolete but this does makes the code simpler.

Thank you Paul.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.