Skip to content

Instantly share code, notes, and snippets.

@eagleon
Created June 17, 2012 15:33
Show Gist options
  • Save eagleon/2944859 to your computer and use it in GitHub Desktop.
Save eagleon/2944859 to your computer and use it in GitHub Desktop.
javascript 按钮事件
<script type="text/javascript">
$(document).ready(function(){
$("input").keypress(function (e) {
var keyCode = e.keyCode ? e.keyCode : e.which ? e.which : e.charCode;
if (keyCode == 13){
var i;
for (i = 0; i < this.form.elements.length; i++)
if (this == this.form.elements[i])
break;
i = (i + 1) % this.form.elements.length;
this.form.elements[i].focus();
return false;
}
else
return true;
});
});
</script>
@eagleon
Copy link
Author

eagleon commented Jun 17, 2012

JavaScript表单enter控制

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment