Reputation: 193
I am stuck with this for hours and I cant figure it out why is that when I enter a letter in the input and call the $().keydown of jQuery and alert it with the $(this).val()
, the first letter that I inputted won't show up but when you input a letter again it shows up.
Is there any explanation for this?
<div class="mainboxforfriendfind">
<div class="findfriend">
<input type="text" id="findtext" name="friendfinder" placeholder="Enter Text to find a friend"/>
<button id="buttonfriend" class="findfriendbutton"></button>
</div>
<div class="outputfindfriend">
</div>
</div>
<script>
$("#findtext").keydown(function () {
alert($(this).val());
});
</script>
Upvotes: 0
Views: 175
Reputation: 148160
Use keyup instead of keydown
$("#findtext").keyup(function () {
alert($(this).val());
});
Upvotes: 2