Warre Buysse
Warre Buysse

Reputation: 1345

value of input field is one character behind

Morning,

When logging my input field the character is always one character behind. When my value field contains 'foo', my logs tells me 'fo'.

Any toughts?

Not much code to show but: (code example is with on-change, i tried it with keyup, keydown, .. same result.

$('#list_search').on('change', searchForBurger);

function searchForBurger(e){
  console.log($(this).val());
}

Thx in advance.

Upvotes: 1

Views: 1294

Answers (1)

Amit
Amit

Reputation: 15387

Try this

 $(function(){
   $('#list_search').on('keyup', searchForBurger);
 });
 function searchForBurger(e){
    alert($(this).val());
 }

 <input type="text" id="list_search" />

Demo

Upvotes: 3

Related Questions