字符串方法

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title></title>
    <script>
        function aa(){
            //先得到輸入框的值
            var unum = document.getElementById("num").value;
            document.getElementById("box").innerText = unum;//把輸入框的值傳到div裏
        }
    </script>
    <style type="text/css">
        div{
            width: 300px;
            height: 300px;
            background-color: yellow;
        }
    </style>
</head>
<body>
    <form>
        <input type="text" id="num"  placeholder="輸入值"/>
        <input type="button" onclick="aa()" />
    </form>
    <div id="box"></div>
</body>

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章