code 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" />