js、jQuery,兼容IE与firefox火狐的回车事件
2017-01-16 10:36
471 查看
js
jQuery
$(document).ready(function(){
$("按下回车的控件").keydown(function(e){
var curKey = e.which;
if(curKey == 13){
$("回车事件按钮控件").click();
return false;
}
});
});
这种方法不可行,不兼容Firefox
$("body").keydown(function() {
if (event.keyCode == "13") {//keyCode=13是回车键
$(document).ready(function(){
$("按下回车的控件").keydown(function(e){
var curKey = e.which;
if(curKey == 13){
$(".回车事件按钮控件").click();
return false;
}
});
});
<script> document.onkeydown=function(event) { e = event ? event : (window.event ? window.event : null); if(e.keyCode==13){ //执行的方法 method(); } } </script>
jQuery
$(document).ready(function(){
$("按下回车的控件").keydown(function(e){
var curKey = e.which;
if(curKey == 13){
$("回车事件按钮控件").click();
return false;
}
});
});
这种方法不可行,不兼容Firefox
$("body").keydown(function() {
if (event.keyCode == "13") {//keyCode=13是回车键
$(document).ready(function(){
$("按下回车的控件").keydown(function(e){
var curKey = e.which;
if(curKey == 13){
$(".回车事件按钮控件").click();
return false;
}
});
});
相关文章推荐
- 兼容IE与firefox火狐的回车事件(js与jquery)
- 兼容IE与firefox火狐的回车事件(js与jquery)
- 兼容IE与firefox火狐的回车事件(js与jquery)
- 兼容IE与firefox火狐的回车事件(js与jquery)(转)
- 兼容IE与firefox火狐的回车事件(js与jquery)
- 兼容IE与firefox火狐的回车事件(js与jquery)
- 兼容IE与firefox火狐的回车事件(js与jquery)
- js阻止浏览器的默认行为以及停止事件冒泡(用JQuery实现回车提交,兼容IE、FF浏览器)
- js阻止浏览器的默认行为以及停止事件冒泡(用JQuery实现回车提交,兼容IE、FF浏览器)
- js阻止浏览器的默认行为以及停止事件冒泡(用JQuery实现回车提交,兼容IE、FF浏览器)
- js阻止浏览器的默认行为以及停止事件冒泡(用JQuery实现回车提交,兼容IE、FF浏览器)
- js阻止浏览器的默认行为以及停止事件冒泡(用JQuery实现回车提交,兼容IE、FF浏览器) 转
- js 判断键盘事件大全 兼容FireFox和IE(退格、制表、回车、空格、方向键、删除键等)
- js 获取回车事件 兼容ie 火狐 谷歌
- 终于成功的做到了兼容IE、FF、google的回车键触发事件(js源代码)
- js 判断键盘事件大全 兼容FireFox和IE(退格、制表、回车、空格、方向键、删除键等)
- js判断回车事件,兼容ie和非ie
- js兼容IE与火狐的回车事件
- javascript 兼容IE与firefox火狐的回车事件
- js 判断键盘事件大全 兼容FireFox和IE(退格、制表、回车、空格、方向键、删除键等)