JS获取键盘事件 判断光标是否选中标签

 

  document.onkeydown = function (event) {console.log(event)}

 

if (document.activeElement.id === 'txtEndTime') {
$('#txtEndTime').val('');
} else if (document.activeElement.id === 'txtStartTime') {
$('#txtStartTime').val('');
}

posted @ 2017-06-20 10:47  joucks  阅读(512)  评论(0编辑  收藏  举报