求解为什么不点击搜索下拉菜单后页面没有跳转打bing界面
HTML:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Bing Search</title>
<link rel="stylesheet" href="../css/搜索框.css">
<script src="../jQuery.js"></script>
<script src="../js/智能提示.js"></script>
</head>
<body>
<div>
<div>
<div></div>
<form action="">
<input class="form-control form-input" id="enter" type="text">
<button class="form-control form-button" type="submit"></button>
</form>
</div>
</div>
<div id="request">
<ul>
</ul>
</div>
</body>
</html>
CSS:
$(window).on("load",function() {
//键盘按键弹起事件
$("#enter").on('keyup click',function() {
//ajax请求bing搜索接口
var searchText = $(this).val();
$.get("http://api.bing.com/qsonhs.aspx?q="+searchText,function(d) {
if (d.AS.Results === undefined) return false;///搜索框文本内容为空时不再执行,否则一直报错
var d1 = d.AS.Results[0].Suggests;
var $d = $(d1);
var html = "";
$d.each(function(index,value) {
html +="<li><a>" + value.Txt + "</a></li>" ;
});
$("#request>ul").html(html);
},"json");
$("#request").show().css({
position: "absolute",
top: $(".box").offset().top + $(".box").height() + "px",
left: $("form").offset().left + "px",
width: $("form").outerWidth() +"px"
});
});
//失去焦点事件
$("#enter").on("blur",function() {
$("#request").hide();
});
//绑定页面跳转事件
$(document).on("click","a",function() {
alert("111");
var searchText = $(this).text();
location.href = "http://cn.bing.com/search?q=" + searchText;
});
})
不知道代码错在哪里了,求大神解答。谢谢!