arix04

 

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

 

【效果演示】

123

【jQuery】下载

/Files/arix04/jquery.rar

分类:

技术点:

相关文章:

  • 2021-12-25
  • 2021-12-15
  • 2021-12-25
  • 2021-12-25
  • 2021-12-25
  • 2022-02-04
  • 2021-09-14
猜你喜欢
  • 2021-11-15
  • 2021-11-05
  • 2021-11-05
  • 2021-12-15
  • 2021-12-15
相关资源
相似解决方案