$('input:not(.topinput)').bind('input propertychange', function() { var $this = $(this); console.log($this); var text_length = $this.val().length;//获取当前文本框的长度 var current_width = parseInt(text_length) *19;//该19是改变前的宽度除以当前字符串的长度,算出每个字符的长度 if(current_width<10){ $this.css("width","20px"); }else{ $this.css("width",current_width+"px"); } });
input长度根据输入内容变化
最新推荐文章于 2023-09-12 10:26:30 发布