Skip to content

Instantly share code, notes, and snippets.

@nitish1402
Created November 17, 2014 08:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nitish1402/1efb2ca34aabaae400e8 to your computer and use it in GitHub Desktop.
Save nitish1402/1efb2ca34aabaae400e8 to your computer and use it in GitHub Desktop.
Basic example of binding data to an input in jQuery // source http://jsbin.com/julav
<!DOCTYPE html>
<html>
<head>
<meta name="description" content="Basic example of binding data to an input in jQuery" />
<script src="http://code.jquery.com/jquery-2.0.3.min.js"></script>
<meta charset="utf-8">
<title>JS Bin</title>
</head>
<body>
<br/><br/>
<div>
Enter your name:
<input name="your-name" id="your-name" type="text"></input>
</div>
<div id="output">Hello</div>
<script id="jsbin-javascript">
$('#your-name').bind('input', function() {
var name = $(this).val();
// now you can use "name" here
$('#output').html("Hello " + name);
});
</script>
<script id="jsbin-source-javascript" type="text/javascript">$('#your-name').bind('input', function() {
var name = $(this).val();
// now you can use "name" here
$('#output').html("Hello " + name);
});</script></body>
</html>
$('#your-name').bind('input', function() {
var name = $(this).val();
// now you can use "name" here
$('#output').html("Hello " + name);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment