Home > DeveloperSection > Forums > Keyup event not fired in JQuery
john rob

Total Post:108

Points:756
Posted on    January-29-2013 2:52 AM

 JQuery JQuery 
Ratings:


 1 Reply(s)
 2385  View(s)
Rate this:

Hi! Everyone!

Keyup event is not fire properly:
I am working with the Keyup method of jQuery and it doesn't seem to work for me. below is my code and please find out the problem and reslove.

My code is below

 <script src="http://code.jquery.com/jquery-1.8.3.js"></script>
    <script src="http://code.jquery.com/ui/1.9.2/jquery-ui.js"></script>
    <script>
      $('#TAcomments').keyup(function() {
        var textCount = $(this).val().length;
        if(textCount <= 10) {
          $('#TAcomments').stop().animate({ fontSize : '22px' });
        }
        if(textCount > 10) {
          $('#TAcomments').stop().animate({ fontSize : '16px' });
        }
        if(textCount > 20) {
          $('#TAcomments').stop().animate({ fontSize : '14px' });
        }
        if(textCount > 30) {
          $('#TAcomments').stop().animate({ fontSize : '10px' });
        }
      });
    </script>

HTML code

 <textarea id="TAcomments" style="width: 400px; height: 300px; font-size: 22px;"></textarea>

Can you help me?

Thanks in advance



AVADHESH PATEL

Total Post:604

Points:4228
Posted on    January-29-2013 9:01 AM

Hi John Rob!

You just overwrite your jquery code with below code

$(document).ready(function(){
    $('#TAcomments').keyup(function() {
        var textCount = $(this).val().length;
        if(textCount <= 10) {
            $('#TAcomments').stop().animate({ fontSize : '22px' });
        }
        if(textCount > 10) {
           $('#TAcomments').stop().animate({ fontSize : '16px' });              
        }
        if(textCount > 20) {
           $('#TAcomments').stop().animate({ fontSize : '14px' });  
        }
        if(textCount > 30) {
           $('#TAcomments').stop().animate({ fontSize : '10px' });  
        }
    });
});


Don't want to miss updates? Please click the below button!

Follow MindStick