jquery - Passing a variable into an alert -


when correct string, foo, entered .guess trying pull value .clicks , pass alert. when load page current code (below) alert reads correct! guessed in clicks.. why clicks variable not being passed?

thanks

jquery:

$('.guess').keyup(function() {      if ($('.guess').val() == "foo") {         var clicks = $('.clicks').val();         alert('correct! guessed in ' + clicks + ' clicks.');         location.reload();     } }); 

html:

<div class="bar">     <h2 class="clicks">0</h2>     <input type="text" class="guess" /> </div> 

.val() used getting value of form input elements.

i think want use $(".clicks").text(), return "0".


Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -