87,910
社区成员
发帖
与我相关
我的任务
分享
function GetWaiGou() {
var Val = $.trim($("#txtName").val());
///判断输入的值
if (Val != "") {
///通过ajax查询出数据
$.getJSON("getWaiGouName.ashx", { "name": Val }, function(data) {
///判断查询出来的数值
if (data.length > 0) {
///加载数值
$("#InfoDiv").html("");
var kk = "<ul>";
$.each(data, function(i, n) {
kk += "<li><a href='#' onclick=\"onClickA('" + n.NM +i+"')\">" + n.NM + i+"</a></li>";
});
kk += "</ul>";
$("#InfoDiv").html(kk);
///显示加载好的数据值
$("#InfoDiv").css({ display: "block" });
}
else {
$("#InfoDiv").html("<ul></ul>");
$("#InfoDiv").css({ display: "none" });
}
});
}
else {
$("#InfoDiv").html("<ul></ul>");
$("#InfoDiv").css({ display: "none" });
}
}
///获得鼠标点击的值
function onClickA(val) {
$("#txtName").val(val);
$("#InfoDiv").css({ display: "none" });
return false;
}
<input onkeyup="GetWaiGou();"/>
<div id="InfoDiv" style=" width:160px; border:1px red solid; float:left; position:relative;z-index:100001; display:block; " >
<ul>
<li><a href="#">asd</a></li>
<li><a href="#" >d</a></li>
</ul>
</div>
ul { margin:0;}/**//*提示层样式*/
ul li{margin:0;list-style-type:none; width:100%; line-height:16px; height:16px; text-decoration:none; font-size:12px; padding:2px;}/**//*提示层样式*/
ul li a{display:block; width:100%; height:16px; text-decoration:none; cursor:default;}/**//*提示层样式*/
ul li a:hover { background:red;}/**//*提示层样式*/