作为前端很差的我,什么都要好好学习
<div class="reason_cancel"> <span>其它说明:(还可输入<font id="chLeft_remark">150</font>个字)</span>
<textarea maxlength="150" οnfοcus="this.placeholder=''" οnblur="this.placeholder='| 请输入...'" placeholder="| 请输入..." οnkeyup="checkLength(this,'1');" style="font-size:12px;" id="cancel_decsription"></textarea>
</div>
前端js:
//字数限制
function checkLength(which,num) {
if(num=="1"){
document.getElementById("chLeft_remark").innerHTML = wordRestrict(which,150).toString();
}
}
function wordRestrict(which,maxChars){
var curr;
if (which.value.length > maxChars)
which.value = which.value.substring(0,maxChars);
curr = maxChars - which.value.length;
return curr;
}