1

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.

4

1 回答 1

3

尝试这个

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

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

演示

于 2013-06-17T09:05:31.893 回答