简体   繁体   中英

Dynamic content dsplay in javascript

如何在另一个文本区域中动态显示文本区域的内容作为用户 id 键入它。这应该通过使用 Javascript 来完成

Try this

    function majText(){
    document.getElementById("textarea2").value = document.getElementById("textarea1").value;
}

<textarea id="textarea1" onKeyUp="majText()"></textarea>

<textarea id="textarea2"></textarea>

or this

function majText(value){
    document.getElementById("textarea2").value = value;
}

<textarea id="textarea1" onKeyUp="majText(this.value)"></textarea>

<textarea id="textarea2"></textarea>

Using jquery:

$(function() {
    $("#TextArea1").keyup(function() { 
        $("#TextArea2").val($("#TextArea1").val());
    });
});

https://jsfiddle.net/3Ldqzax9/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM