js两个input框内容同步

<body>
    <input type="text" id="t1" > <br>
    <input type="text" id="t2" >
</body>
<script>
    document.getElementById(t1).oninput = function(){
        document.getElementById(t2).value = this.value;
    }
</script>