autofill input field with value of another input f

2019-01-23 08:49发布

问题:

I'm going crazy about this. I found a plain JavaScript solution for my problem:

<script type="text/javascript" language="JavaScript" src=""> 

s1 = new String(catwebformform43575.EmailAddress.value)

function changeVal() {

    document.catwebformform43575.Username.value = catwebformform43575.EmailAddress.value;

}

</script>

<BR>
<BR>
<form name="catwebformform43575">
 <input type="text"id="EmailAddress" name="EmailAddress" value="" onkeyup = "changeVal()">
 <input type="text" id="Username" name="Username" value="">

but I need a jQuery solution...Can anybody help?

回答1:

$("#EmailAddress").keyup(function(){
    $("#Username").val(this.value);
});

See a working demo



标签: jquery input