layui实现文本域输入字数的限制
css部分:
.layui-input-block { position: relative; } .word { position: absolute; right: 10px; bottom: 10px; color: #aaa; font-size: 12px; }
html部分:
0 / 100
js部分:
//字数限制
function wordLeg (obj) { var currleg = $(obj).val().length; var length = $(obj).attr('maxlength'); if (currleg > length) { layer.msg('字数请在' + length + '字以内'); } else { $('.text_count').text(currleg); } }