Keyup event not fired in JQuery

Total Post:108

Points:756

JQuery 
 3649  View(s)
Ratings:
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

  1. Re: Keyup event not fired in JQuery

    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' });   
            }
        });
    });

      Modified On Mar-29-2018 06:17:06 AM

Answer

Please check, If you want to make this post sponsored

You are not a Sponsored Member. Click Here to Subscribe the Membership.