js 监听input 按下回车键事件

180it 2020-02-16 AM 7415℃ 0条
 <input type="text" id="searchAll" value="" onkeydown="keyDown(event)" placeholder="搜索节目" onfocus="if (this.value == '搜索节目' || this.value == '搜索节目') { this.value = ''; this.style.color = 'black';}; " onblur="if (this.value == '' || this.value == '搜索节目') { this.value = '搜索节目'; this.style.color = '#ccc'; }" style="color: rgb(204, 204, 204);">

<script>
function keyDown(e) {
    var ev = window.event||e;
    //13是键盘上面固定的回车键
    if (ev.keyCode == 13) {
        document.writeln('回车键按下');  
    //searchDetail(); 查询事件
    }
}
</script>
支付宝打赏支付宝打赏 微信打赏微信打赏

如果文章或资源对您有帮助,欢迎打赏作者。一路走来,感谢有您!

标签: none

js 监听input 按下回车键事件