JQuery: current update of input value

This is where I started, and it changes the # user_name input when the script is run. How do I get it to update the value?

var $username = $("input#user_email").val();

$("input#user_name").val($username);

      

+3


source to share


2 answers


$("input#user_email").keyup(function(){
  $("input#user_name").val($(this).val());
});

      



if you mean that when you type user_email you want on user_name

+6


source


$(function(){
  $('input#user_email').bind('keyup',function(){
     $("input#user_name").val($(this).val());
  });

});

      



+4


source







All Articles