js中回车事件的捕杀js中回车事件的捕杀
c_a_3();
js中回车事件的捕捉
下面给一个例子,回车触发按钮的onclick事件。
html
head title keydown /title /head
script
function strdown(event){
if(event.keyCode==13){
//event.keyCode=0; //取消回车
document.getElementByIdx( str ).click();
return false;
}
}
function test(){
...
js中回车事件的捕杀
c_a_3();
js中回车事件的捕捉
下面给一个例子,回车触发按钮的onclick事件。
html
head title keydown /title /head
script
function strdown(event){
if(event.keyCode==13){
//event.keyCode=0; //取消回车
document.getElementByIdx( str ).click();
return false;
}
}
function test(){
alert( ok );
}
/script
body onkeydown= strdown(event)
input type= button id= str onclick= test() value= button /
/body
/html
再来看一个用jquery写的例子。
html
head title keydown /title
script type='text/javascript' src='jquery-1.3.1.min.js' /script
/head
script
$(document).ready(function(){
$(document).keydown(function(event){ //这里如果写成$(window),在ie下面就不会起作用
if(event.keyCode==13){
document.getElementByIdx( str ).onclick();
return false;
}
});
});
function test(){
var s = document.getElementByIdx( a ).value;
alert(s);
}
/script
body
input type= text id= a /
input type= button id= str onclick= test() value= button /
/body
/html
本文档为【js中回车事件的捕杀】,请使用软件OFFICE或WPS软件打开。作品中的文字与图均可以修改和编辑,
图片更改请在作品中右键图片并更换,文字修改请直接点击文字进行修改,也可以新增和删除文档中的内容。
[版权声明] 本站所有资料为用户分享产生,若发现您的权利被侵害,请联系客服邮件isharekefu@iask.cn,我们尽快处理。
本作品所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用。
网站提供的党政主题相关内容(国旗、国徽、党徽..)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。