日期:2014-05-16 浏览次数:20502 次
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=GBK" /> <title>仿百度搜索输入框提示JS代码</title> <link href="css/jquery.autocomplete.css" type=text/css rel=stylesheet> <script type="text/javascript" src="js/jquery.js"></script> <script type="text/javascript" src="js/jquery.autocomplete.js"></script> <script language="javascript"> $(document).ready(function() { $("#keyword").autocomplete("getajaxtag.php", { delay:10, minChars:1, matchSubset:1, matchContains:1, cacheLength:10, onItemSelect:selectItem, onFindValue:findValue, formatItem:formatItem, autoFill:false } ); }); function findValue(li) { if( li == null ) return alert("No match!"); if( !!li.extra ) var sValue = li.extra[0]; else var sValue = li.selectValue; } function selectItem(li) { findValue(li);} function formatItem(row) { return row[0];//return row[0] + " (id: " + row[1] + ")"//如果有其他参数调用row[1],对应输出格式Sparta|896 } function lookupAjax(){ var oSuggest = $("#keyword")[0].autocompleter; &nbs