宝哥软件园

jQuery实现简易的输入框字数计数功能示例

编辑:宝哥软件园 来源:互联网 时间:2021-09-06

本文实例讲述了jQuery实现简易的输入框字数计数功能。分享给大家供大家参考,具体如下:

运行效果图如下:

具体代码如下:

!DOCTYPE html html lang=' en ' head meta charset=' UTF-8 ' title/title script src=' http : jquery-1。7 .2 .量滴js '/script/head dydiv class=' container '输入id=' ABC '值='我们span id=' WordCountShow '/span/div script $。fn。extend({ WordCount:函数(MaxLength,Wordwrapper){ var self=this;$(自我)。attr('maxlength ',MaxLength);showWordCount();$(这个)。on('input propertychange ',showWordCount);函数showWordCount(){ croplenth=$(self).val().长度;var休假计数=MaxLength-CoLlength;wordpwrapper。文本(离开计数/' MaxLength);} } }) $(函数(){ $('#abc ').字数(10,$(' # WordCountShow ');})/脚本/正文/htmlPS:这里再为大家提供几款带有字数统计功能的在线工具供大家参考使用:

在线字数统计工具:http://工具。JB 51。net/code/zishhutonji

在线文本美化排版工具:http://工具。JB 51。net/aidesign/txt _ paiban

在线自动排版与转换工具:http://工具。JB 51。net/aiddesign/txt _ beaut

更多关于jQuery相关内容感兴趣的读者可查看本站专题: 《jQuery常用插件及用法总结》 、 《jQuery扩展技巧总结》 、 《jQuery切换特效与技巧总结》 、 《jQuery遍历算法与技巧总结》 、 《jQuery常见经典特效汇总》 、 《jQuery动画与特效用法总结》 及《jquery选择器用法总结》

希望本文所述对大家jQuery程序设计有所帮助。

更多资讯
游戏推荐
更多+