亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

文博文本輸入框完整版

Original 2019-02-06 11:29:28 240
abstract:在這個案例做完后,測試為空的時候。一點就成功發(fā)布。糾結死了。反復找問題,最后是m沒初始化。只有鍵盤有響應了他才獲得值。最后在前面給他初始化賦值150就沒問題了。這個都不重要,重要的是這個問題是靠自己揪出來的。滿滿的收獲。<!DOCTYPE html><html><head><meta charset="UTF-8"><met

在這個案例做完后,測試為空的時候。一點就成功發(fā)布。糾結死了。反復找問題,最后是m沒初始化。只有鍵盤有響應了他才獲得值。最后在前面給他初始化賦值150就沒問題了。這個都不重要,重要的是這個問題是靠自己揪出來的。滿滿的收獲。



<!DOCTYPE html>

<html>

<head>

<meta charset="UTF-8">

<meta name="viewport" content="width=device-width, initial-scale=1.0">

<meta http-equiv="X-UA-Compatible" content="ie=edge">

<title>微博輸入</title>

<style>

body{font-size: 12px;}

.box{width: 600px;height: 180px; border:7px solid pink;margin:50px auto;}

.box img{float:left;margin-left: 10px;}

.box1{float:right;/* margin-right: 50px; */width: 150px;height: 24px;font-size:14px;color: #888;line-height: 24px;}

.box1 span{font-size: 16px;font-weight: bold;}

#text{width: 584px;height: 100px;border:1px solid #888;margin:5px;resize:none;padding: 5px}

.box .sp1{float: left;width: 30px;height: 32px;line-height: 32px;padding-left: 26px;}

#sp1{background: url(img/images1/an5.png) no-repeat left center;}

#sp2{background: url(img/images1/an4.png) no-repeat left center;}

#sp3{background: url(img/images1/an3.png) no-repeat left center;}

#sp4{background: url(img/images1/an2.png) no-repeat left center;}

#sp5{background: url(img/images1/an1.png) no-repeat left center;width: 40px;}

#sp6{margin-left: 150px;margin-right: 15px;color:#888;}

#bt{float:left;width: 80px;height: 30px;border: none;background: #ffc09f;color:#fff;border-radius: 5px;}

</style>

<script>

var text,number,m;

window.onload=function(){

text = document.getElementById('text');

number = document.getElementById('number');

bt = document.getElementById('bt');

m = 150;

           text.onkeyup = function aa() {

m = 150-text.value.length

if (m<0) {

                   number.style.color="red";

}else{

                   number.style.color="#888";

}

               number.innerHTML=m;

}

           bt.onclick = function(){

if(m==150){

alert("內容不能為空!");

                   text.focus();//光標自動到textarea

}else if(m<0){

alert("字數(shù)超過限制,不能發(fā)布。")

                   text.focus();

}else{

alert("發(fā)布成功!")

}

}

}

</script>

</head>

<body>

<div>

<img src="img/images1/12.png" alt="">

<div>還可以輸入:<span id="number">150</span>字</div>

<textarea id="text"onclick="aa()" placeholder="有新鮮事,記得分享給大家哦!"></textarea>

<span id="sp1">表情</span>

<span id="sp2">圖片</span>

<span id="sp3">視頻</span>

<span id="sp4">話題</span>

<span id="sp5">長微博</span>

<span id="sp6">公開</span>

<input type="button" id="bt" value="發(fā)布">

</div>

</body>

</html>



Correcting teacher:滅絕師太Correction time:2019-02-11 09:28:48
Teacher's summary:非常好啊,老師的代碼是帶有測試性的,完善的很好

Release Notes

Popular Entries