简单的数据绑定

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>数据绑定</title>
    <style>
        .col {
            width: 200px;
            height: 100px;
            background-color: #5bfff8;
            font-size: 16px;
        }
    </style>
</head>
<body>
<input type="text" id="txtValue">
<div class="col"></div>
<script>
    var txtInput = document.querySelector('#txtValue');
    var div = document.querySelector('.col');
    function keyUpHandle(e) {
        div.innerHTML = txtInput.value
    }
    txtInput.onkeyup = keyUpHandle;
</script>
</body>
</html>
posted @ 2017-10-01 17:26  加岐  阅读(121)  评论(0)    收藏  举报