Chinaunix首页 | 论坛 | 博客
  • 博客访问: 531915
  • 博文数量: 59
  • 博客积分: 1169
  • 博客等级: 少尉
  • 技术积分: 572
  • 用 户 组: 普通用户
  • 注册时间: 2011-04-01 18:03
个人简介

信息量太大,每天疲于辨别信息得真伪。

文章分类

全部博文(59)

文章存档

2016年(1)

2014年(9)

2013年(1)

2011年(48)

分类: 系统运维

2011-07-21 13:25:53

  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

  2. <html>
  3. <head>
  4. <title>Untitled</title>
  5. <script src="jquery-1.3.2.js"></script>
  6. <script src="jquery-1.3.2.min.js"></script>
  7. <script language="javascript">
  8. $(function(){
  9.     jQuery.fn.extend({
  10.         showWordCount: function() {
  11.             var _max = $(this).attr('max');
  12.             var _length = $(this).text().length;
  13.             if(_length > _max) {
  14.                 $(this).text($(this).text().substring(0, _max));
  15.             }
  16.             _left = $(this).offset().left;
  17.             _top = $(this).offset().top;
  18.             _width = $(this).width();
  19.             _height = $(this).height();
  20.             $('#div_1').html(_length + '/' + _max);
  21.             $('#div_1').css({
  22.                 'left':_left + _width - 60,
  23.                 'top':_top + _height - 8
  24.             });
  25.         }
  26.     });
  27.     
  28.     $('textarea').bind('propertychange', function() {
  29.         $(this).showWordCount();
  30.     });
  31.     
  32.     $('textarea').focus(function(){
  33.         $(this).showWordCount();
  34.         $('#div_1').fadeIn('slow');
  35.     });
  36.     
  37.     $('textarea').blur(function(){
  38.            $('#div_1').fadeOut('slow');
  39.     });
  40. });
  41. </script>
  42. <style>
  43. .div_1 {
  44.     position:absolute;
  45.     font-size:9pt;
  46.     color:#4586b5;
  47.     width:50px;
  48.     text-align:right;
  49.     display:none
  50. }
  51. </style>
  52. </head>

  53. <body>
  54. <center>
  55. <textarea id="textarea_1" cols=50 rows=10 max="100">123</textarea>
  56. <div id="div_1" class="div_1">123</div>
  57. </center>
  58. </body>
  59. </html>


阅读(4522) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~