Title: Textbox bind keydown event failure Post by: wymak on December 26, 2016, 03:46:16 AM I write a short code to display the number of character user input into the textbox, on each textbox.keydown event.
However, the code did not work for user input greater than 1 character. It work again if I put an 'alert()' function inside, as shown, please enlighten me..... <input id='title' class='easyui-textbox'> </div> <div id='count'></div> <script type="text/javascript"> $(function(){ $('#title').textbox('textbox').bind('keydown', function (e) { s = $('#title').val(); cnt = (s.length+1).toString(); // uncomment the following and the program will work //alert(cnt); $('#count').text(cnt); }); }); // end $function() </script> Title: Re: Textbox bind keydown event failure Post by: jarry on December 26, 2016, 07:09:55 AM Please use this code instead.
Code: $('#title').textbox('textbox').bind('keydown', function (e) { s = $(this).val(); //... |