$(function(){ 
 jQuery.fn.extend({ 
        showWordCount: function() { 
            var _max = $(this).attr('max');
   var _length = $(this).text().length;
   if(_length > _max) {
    $(this).text($(this).text().substring(0, _max));
   }
   _left = $(this).offset().left;
   _top = $(this).offset().top;
   _width = $(this).width();
   _height = $(this).height();
   $('#div_1').html(_length + '/' + _max);
   $('#div_1').css({
    'left':_left + _width - 105,
    'top':_top + _height - 16
   });
        } 
    });
 
 $('textarea').bind('propertychange', function() {
  $(this).showWordCount();
 });
 
 $('textarea').focus(function(){ 
  $(this).showWordCount();
     $('#div_1').fadeIn('slow');
 });
 
 $('textarea').blur(function(){
        $('#div_1').fadeOut('slow');
 });
});

 

【效果演示】

相关文章:

  • 2022-12-23
  • 2021-10-31
  • 2021-06-04
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-12-15
  • 2021-12-15
  • 2021-12-15
  • 2022-02-04
  • 2021-07-27
  • 2022-12-23
相关资源
相似解决方案