标签:arch which nbsp span app 点击 sea targe attr
例如回车事件(keyCode为13),选择器class为“search-term”,触发方法为searchTermInfo();
document.onkeydown = function (event)
{
var event = event || window.event;
var target = event.srcElement || event.target;
if (event.keyCode == 13 && target.getAttribute("class") == "search-term")
{
searchTermInfo();
}
}
不设定选择器,在窗口点击,返回的是event.which 值,即按键的keycode:
$(window).keydown( function(event){
$("body").append( "<br>你按下的按键的代码值为:[" + event.which + ‘]‘ ) ;
} );
标签:arch which nbsp span app 点击 sea targe attr
原文地址:http://www.cnblogs.com/dcysc/p/6058254.html