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

JS案例--微博輸入字數(shù)

??? 2019-04-01 16:58:43 286
????:<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>微博輸入</title> <style>     *{margin:0;padding:0;}  &nbs
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>微博輸入</title>
<style>
    *{margin:0;padding:0;}
        .box{
         width:650px;
         height:180px;
         border:10px solid blue;
         margin:10px auto;
         padding:10px;
        }
        img{

         float:left;
        }
        .box2{
         width:150px;
         height:24px;
         float:right;
         line-height:24px;
         text-align:right;
         font-size:14px;
        }
        .clear{
         clear:both;
        }
        #text{
         width:650px;
         height:115px;
         border:1px solid #000;
         margin:10px 0 5px;
        }
        ul li{
         list-style:none;
         float:left;
         margin-left:10px;
        }
        span{
         font-size:10px;
        }
        p{
         float:right;
         font-size:14px;
         margin-right:20px;
         line-height:24px;
        }
        button{
         border:none;
         border-radius:5px;
         width:70px;
         background:#FFC09F;
         text-align:center;
         color:#fff;
         line-height:28px;
         float:right;
         margin-top:-3px;
        }
        .box2 span{
         font-size:20px;
         font-weight:800;
        }
</style>
</head>
<body>
<div class="box">
        <img src="images/12.png" alt="">
        <div class="box2">還可以輸入<span id="number"></span>字</div>
        <div class="clear"></div>
        <textarea id="text"></textarea>
        <ul>
         <li>
                <img src="images/an5.png" alt=""><span>表情</span>
         </li>
         <li>
                <img src="images/an4.png" alt=""><span>圖片</span>
         </li>
         <li>
                <img src="images/an3.png" alt=""><span>視頻</span>
         </li>
         <li>
                <img src="images/an2.png" alt=""><span>話題</span>
         </li>
         <li>
                <img src="images/an1.png" alt=""><span>長微博</span>
         </li>
        </ul>
        <button id="bt">發(fā)布</button>
        <p>公開</p>
</div>

<script>
        var text,number,m;
        window.onload=function(){
         text=document.getElementById('text');
         number=document.getElementById("number");
         bt=document.getElementById("bt");
         text.onkeyup=function aa(){
         m=140-text.value.length;
         if(m<0){
         number.style.color="red";
         }else{
         number.style.color="#888";
         }
         number.innerHTML=m;
         }
         bt.onclick=function(){
         if(m==140){
         alert("你還沒有輸入內(nèi)容");
         text.focus();
         }else if(m<0){
         alert("你的內(nèi)容輸入過多,不能發(fā)布");
         text.focus();
         }else{
         alert("發(fā)布成功");
         }
         }
         aa();
        }
</script>
</body>
</html>

總結(jié):本節(jié)課學(xué)習(xí)的是JS案例--微博輸入字數(shù),前面的布局是自己敲出來的,后面的JS代碼是根據(jù)老師的步驟敲出來的,現(xiàn)在自己還不能完全脫離老師的代碼敲出來,還是要多加練習(xí)。

?? ???:西門大官人?? ??:2019-04-02 10:36:01
???? ??:孰能生巧,多寫代碼,思路就清晰了。繼續(xù)加油

??? ??

?? ??