js文本框回车事件

js代码

$("#b-text").keypress(function(){
if(event.keyCode == 13){
var value=$("#b-text").val();
if(value.length > 0){
window.location="http://www.baidu.com/";
}else{
window.location="index.html";
}
}
});

html代码:

<input type="text" name="b-text" id="b-text" class="b-text"/>

posted @ 2020-04-18 23:42  一天从晚上开始  阅读(1825)  评论(0编辑  收藏  举报