abstract:var num,total,bt,m; window.onload = function ( ) { num = document.getElementById("number"); bt = document.getElementById("bt"); docu
var num,total,bt,m;
window.onload = function ( ) {
num = document.getElementById("number");
bt = document.getElementById("bt");
document.getElementById("text").onkeypress=function aa ( )
{
total = document.getElementById("text").value.length;
m = 140-total;
// aler(total)
if(m>0)
{
num.style.color="#888";
}else
{
num.style.color="red";
}
num.innerHTML=m;
}
bt.onclick=function(){
if (m==140) {
alert("你还没有输入")
document.getElementById("text").focus()
}else if(m<0){
alert("字数太多,不可以发布")
document.getElementById("text").focus()
}else{
alert("发布成功")
}
}
aa();
}
Correcting teacher:灭绝师太Correction time:2019-03-20 09:33:23
Teacher's summary:代码提交全面哦,案例也可以跳出老师上课代码!