<div class="content">
<textarea class="textarea" placeholder="请输入内容" maxlength="60" id="context"></textarea>
<div class="input-num">
<span id="tips">0</span>
/60字
</div>
</div>
.content {
position: relative;
width:500px;
height:160px;
}
.content .textarea {
font-size: 14px;
color: #333;
padding: 12px 15px;
width: 100%;
height: 100%;
border: solid 1px #e7e7e7;
vertical-align: top;
resize: none;
box-sizing: border-box;
}
.content .input-num {
display: block;
position: absolute;
bottom: 6px;
right: 10px;
font-size: 12px;
color: #999;
}
$(function () {
var text = $('#context').val();
var len = text.length;
$('#tips').html(len);
$('#context').keyup(function () {
var text = $(this).val();
len = text.length;
if (len > 60) {
return false;
}
$("#tips").html(len);
})
})
欢迎光临 苏飞论坛 (http://www.sufeinet.com/) | Powered by Discuz! X3.4 |