Stephen Way
Stephen Way

Reputation: 678

jQuery: Live Update Value of Input

This is what I've started out with and it only changes input#user_name upon running the script. How do I get it to live update the value?

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

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

Upvotes: 3

Views: 16577

Answers (2)

gastonfartek
gastonfartek

Reputation: 348

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

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

Upvotes: 6

Toni Michel Caubet
Toni Michel Caubet

Reputation: 20163

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

});

Upvotes: 4

Related Questions