Skip to content

Instantly share code, notes, and snippets.

@nola
Created November 26, 2013 02:27
Show Gist options
  • Select an option

  • Save nola/7652582 to your computer and use it in GitHub Desktop.

Select an option

Save nola/7652582 to your computer and use it in GitHub Desktop.
$(“#name”) tells jQuery to deal with element id=’name’. .keyup(updateName) calls jQuery keyup method and tells it to run updateName function whenever it detects keystroke on #name element. The first line of updateName() function makes use of jQuery val() method to read the current value of #name input. It will then store that value inside ‘name’…
$("#name").keyup(updateName)
function updateName() {
var name=$("#name").val();
$("#user-name").text(name);
}
<input id="name" placeholder='Type your name'>
<h2>Welcome </h2>
<h2 id="user-name"></h2>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment