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

微博輸入的html+css+javascript

原創(chuàng) 2019-02-02 13:03:43 284
摘要:<!DOCTYPE html> <html>          <head>         <meta charset="UTF-8">  
<!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: 160px;
            border: 8px solid pink;
            margin: 0 auto;
            padding: 10px;
        }
        img {
            float: left;
        }
        .box-num {
            float: left;
            margin-left: 255px;
            width: 150px;
            height: 24px;
            font-size: 14px;
            text-align: right;
            color: #888;
        }
        .box-num span {
            font-size: 16px;
            font-weight: bold;
        }
        #text {
            width: 594px;
            height:100px;
            border: 1px solid #ccc;
            margin-top: 5px;
            clear: both;
        }
        .box .item1, .item2, .item3, .item4, .item5, .item6 {
            float: left;
            width: 30px;
            height: 36px;
            line-height: 32px;
            padding-left: 26px;
        }
        .item1 {
            background: url(images/an5.png) no-repeat left center;
        }
        .item2 {
            background: url(images/an4.png) no-repeat left center;
        }
        .item3 {
            background: url(images/an3.png) no-repeat left center;
        }
        .item4 {
            background: url(images/an2.png) no-repeat left center;
        }
        .item5 {
            background: url(images/an1.png) no-repeat left center;
            width: 40px;
        }
        .item6 {
            margin-left: 160px;
            margin-right: 14px;
            color: #888;
        }
        #but {
            float: left;
            border: none;
            background: #ff6500;
            color: #fff;
            width: 80px;
            height: 30px;
            border-radius: 5px;
        }
        </style>
        <script>
            var text, number, m, but;
            window.onload = function() {
                text = document.getElementById('text');
                number = document.getElementById('number');
                but = document.getElementById('but');
                text.focus();
                text.onkeyup = function aa() {
                    m = 140 - text.value.length;
                    if (m < 0) {
                        number.style.color = 'red';
                    } else {
                        number.style.color = '#888';
                    }
                    number.innerHTML = m;
                }

                but.onclick = function() {
                    if (text.value == "") {
                        alert('你沒有輸入內容');
                        text.focus();
                    } else if (m < 0) {
                        alert('你輸入的內容超過了140個字');
                        text.focus();
                    } else {
                        alert('發(fā)布成功')
                    }
                }
                a();
            }
        </script>
    </head>
    
    <body>
        <div class="box">
            <img src="images/12.png">
            <div class="box-num">還可以輸入<span id="number">140</span>字</div>
            <textarea id="text"></textarea> <span class="item1">表情</span>
 <span class="item2">圖片</span>
 <span class="item3">視頻</span>
 <span class="item4">話題</span>
 <span class="item5">長微博</span>
 <span class="item6">公開</span>

            <input type="button" value="發(fā)布" id="but">
        </div>
    </body>

</html>

如果按鈕提交if語句使用 m==8,默認進入不進行操作點擊提交按鈕,會提示發(fā)布成功,使用text.value == "",就不會出現(xiàn)這個問題。

批改老師:韋小寶批改時間:2019-02-02 13:40:49
老師總結:寫的很不錯 通過這種案例可以練習我們的前端基礎 沒事要多練習練習哦!

發(fā)佈手記

熱門詞條