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

时间:2021-08-12  来源:jquery  阅读:

运行效果图如下:

具体代码如下:




  
  
  <script src="jquery-1.7.2.min.js"></script>



  

<script>
  $.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"));
  })
</script>

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

http://m.bbyears.com/wangyezhizuo/135568.html

推荐访问:
相关阅读 猜你喜欢
本类排行 本类最新