欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

js鍵盤(pán)上下左右鍵怎么觸發(fā)function(實(shí)例講解)

 更新時(shí)間:2013年12月14日 09:16:01   作者:  
這篇文章主要是對(duì)js鍵盤(pán)上下左右鍵怎么觸發(fā)function 進(jìn)行了詳細(xì)的分析介紹,需要的朋友可以過(guò)來(lái)參考下,希望對(duì)大家有所幫助

復(fù)制代碼 代碼如下:

<script type="text/javascript">
 function jumpPage() {
    if (event.keyCode==37)//左
fun_a();
if (event.keyCode==38)//上
 fun_b();
 if (event.keyCode==39)//右
fun_c();
if (event.keyCode==40)//下
fun_d();
 }


 

function fun_a(){
window.alert('你按下了左')
 }

function fun_b(){
window.alert('你按下了上')
}

function fun_c(){
window.alert('你按下了右')
}

function fun_d(){
 window.alert('你按下了下')
}
document.onkeydown=jumpPage;

</script>


HTML code
復(fù)制代碼 代碼如下:

<table width="100%" border="1" cellspacing="1" cellpadding="0" id=table> <tr id="lineone" style="background-color:#00cccc;"> <td id=aa height="23">&nbsp;</td> <td id=aa >按向下鍵</td> <td id=cc >按向下鍵</td> <td id=dd >按向下鍵</td> <td id=ee >按向下鍵</td> </tr> <tr id="linetwo" tyle="background-color:#ffffff;"> <td id=a height="23">&nbsp;</td> <td id=b >按向上鍵</td> <td id=c >按向上鍵</td> <td id=d >按向上鍵</td> <td id=e >按向上鍵</td> </tr></table><script language="javascript"> function keyDown(e) { var iekey=event.keyCode; action(iekey); } document.onkeydown = keyDown; function action(iekey) { if(iekey==40) { lineone.style.backgroundColor = ""; linetwo.style.backgroundColor = "#00cccc"; } if(iekey==38) { lineone.style.backgroundColor = "#00cccc"; linetwo.style.backgroundColor = ""; } } </script><input name="id" type="hidden" id="id" value

相關(guān)文章

最新評(píng)論