EasyUI Forum
July 17, 2024, 02:38:21 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Textbox bind keydown event failure  (Read 7364 times)
wymak
Newbie
*
Posts: 26


View Profile
« 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>
Logged
jarry
Administrator
Hero Member
*****
Posts: 2269


View Profile Email
« Reply #1 on: December 26, 2016, 07:09:55 AM »

Please use this code instead.
Code:
$('#title').textbox('textbox').bind('keydown', function (e) {
  s = $(this).val();
  //...
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!