*新闻详情页*/>
本文实例讲述了jQuery实现简易的输入框字数计数功能。分享给大家供大家参考,具体如下:
运行效果图如下:
具体代码如下:
!DOCTYPE html html lang="en" head meta charset="UTF-8" title /title script src="jquery-1.7.2.min.js" /script /head body div input id="abc" value="凡科" span id="wordCountShow" /span /div script $.fn.extend({ wordCount: function (maxLength, wordWrapper) { var self = this; $(self).attr("maxlength", maxLength); showWordCount(); $(this).on("input propertychange", showWordCount); function showWordCount() { curLength = $(self).val().length; var leaveCount = maxLength - curLength; wordWrapper.text(leaveCount + "/" + maxLength); $(function () { $("#abc").wordCount(10, $("#wordCountShow")); /script /body /html
凡科抠图:这里再为大家提供几款带有字数统计功能的在线工具供大家参考使用:
在线字数统计工具:
在线文本美化排版工具:
在线自动排版与转换工具:
更多关于jQuery相关内容感兴趣的读者可查看本站专题:《》、《》、《》、《》、《》、《》及《》
希望本文所述对大家jQuery程序设计有所帮助。
Copyright © 2002-2020 上线了小程序官网_年会抽奖小程序免费_做小程序_小程序网站_跑腿小程序 版权所有 (网站地图) 粤ICP备10235580号