Copy another textbox value in real time Jquery

后端 未结 5 669
臣服心动
臣服心动 2021-01-06 09:30

I want to get the value of another textbox and input it in realtime into the other textbox. HOW CAN I DETECT IF TEXT_3 WAS CHANGED? IF TEXT_3 VALUE CHANGED, IT MUST BE INPU

5条回答
  •  长情又很酷
    2021-01-06 09:33

    The problem is that you can't bind special event to check that the textbox value was changed using JavaScript and not manually. To solve the task, one option is to use the same keyup event for both text_1 and text_2. JQuery will add the new handler to the existing handlers:

    $("#text_1, #text_2").keyup(function(){
        $("#text_4").val($("#text_3").val());
    })
    

    DEMO: http://jsfiddle.net/8eXRx/11/

提交回复
热议问题