Skip to content

Instantly share code, notes, and snippets.

@panesofglass
Forked from mattpodwysocki/LetterCount.html
Created March 14, 2010 19:38
Show Gist options
  • Save panesofglass/332170 to your computer and use it in GitHub Desktop.
Save panesofglass/332170 to your computer and use it in GitHub Desktop.
mattpodwysocki: Quick letter counter from FlapJax demos to RxJS and jQUery
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>Letter Count</title>
<link rel="stylesheet" href="demo.css"/>
<style type="text/css">
body {text-align: center;
background-color: #CCFFCC;
color: #006600;}
</style>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script src="rx.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function() {
$("#toCount")
.ToObservable("keyup")
.Subscribe(function(event) {
$("#result").html("length: " + $("#toCount").val().length);
});
});
</script>
</head>
<body>
<p>Text buffer: <input type="text" id="toCount"></p>
<p id="result">Start Typing!</p>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment