最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
jQuery实现简易的输入框字数计数功能示例
时间:2017-01-20 编辑:简简单单 来源:一聚教程网
本文实例讲述了jQuery实现简易的输入框字数计数功能。分享给大家供大家参考,具体如下:
运行效果图如下:
具体代码如下:
代码如下 | 复制代码 |
$.fn.extend({ wordCount:function(maxLength, wordWrapper) { varself =this; $(self).attr("maxlength", maxLength); showWordCount(); $(this).on("input propertychange", showWordCount); functionshowWordCount() { curLength = $(self).val().length; varleaveCount = maxLength - curLength; wordWrapper.text(leaveCount +"/"+ maxLength); } } }) $(function() { $("#abc").wordCount(10, $("#wordCountShow")); }) |
-
上一个: jQuery插件扩展操作入门示例
-
下一个: js实现导航栏中英文切换效果