同步文本框中的信息(三)

3.在一个文本框输入信息时,在另一个文本框同步显示(onkeyup)
<!DOCTYPE html>
<html>
<head>

</head>
<body>

        <!-- onkeypress:当键被按下并松开时起作用,会导致第二个同步框比第一个迟缓一步
             onkeydown:当键被按下时起作用,同样会迟缓一步
             onkeyup,当键松开时起作用-->
    <input id="one" onkeyup="changefun()">
    <input id="two">
    
</body>

<script type="text/javascript">

    
    function changefun() {
        // var val = document.getElementById("one").value;
        // document.getElementById("two").innerHTML = val;
        document.all["two"].value = document.all["one"].value;
    }
     
</script>
</html>
发布了36 篇原创文章 · 获赞 50 · 访问量 9753

猜你喜欢

转载自blog.csdn.net/qq_41765969/article/details/103300996