JQuery - Duplicate Field Input Text In Real Time

前端 未结 5 2086
盖世英雄少女心
盖世英雄少女心 2020-12-23 23:39

I\'m trying to figure out how to copy a users text input in one form field to another. Specifically, when someone fills in their email address in the contact form, it will b

5条回答
  •  情话喂你
    2020-12-24 00:06

    Since all your fields have unique ids, this is quite straight forward:

    $(function() {                                       // <== Doc Ready
        $("#email").change(function() {                  // When the email is changed
            $('#mail').val(this.value);                  // copy it over to the mail
        });
    });
    

    Try it out with this jsFiddle


    .change()
    .val()

提交回复
热议问题