Advertisement
Mihalytch

калькулятор символов

Feb 28th, 2013
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. (function($){
  2.     var timeout_id;
  3.    
  4.     // Document Ready
  5.     $(document).ready(function(){
  6.         var text_len = 0;
  7.         var $ads_text = jQuery('textarea#text');
  8.         var $text_len_counter = jQuery('#text_len_counter');
  9.        
  10.         $ads_text.keyup(function() {
  11.             text_len = $ads_text.val().length;
  12.            
  13.             if (timeout_id) {
  14.                 clearTimeout(timeout_id)
  15.             }
  16.             timeout_id = setTimeout(function(){
  17.                 runTextCalc();
  18.             }, 200);
  19.         });
  20.        
  21.         var runTextCalc = function() {
  22.             $text_len_counter.html(text_len);
  23.         }
  24.     });
  25. })(jQuery);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement