Created
October 20, 2011 13:59
-
-
Save athurg/1301205 to your computer and use it in GitHub Desktop.
用于检测回车键的Javascript代码
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
function cb(obj) | |
{ | |
var div; | |
div = document.getElementById("adiv"); | |
div.innerHTML=obj.name+" enter :"; | |
if (event.keyCode==13) | |
div.innerHTML+="Return"; | |
else | |
div.innerHTML+=event.keyCode; | |
} | |
</script> | |
<div id="adiv"></div> | |
<input name=i onkeypress=cb(this) /> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment