87,985
社区成员




<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<link href="../JS/autocomplete/jquery.autocomplete.css" rel="stylesheet" />
</head>
<body>
<input type="text" id="input1" />
</body>
</html>
<script src="../JS/jquery-1.7.min.js"></script>
<script src="../JS/autocomplete/jquery.autocomplete.min.js"></script>
<script type="text/javascript">
$(function () {
var data = [{ text: 'Link A', url: '/page1' }, { text: 'Link B', url: '/page2' }];
$("#input1").autocomplete(data, {
matchContains: true,
formatItem: function (item, index, counts) {
if (counts == 1) {
$('#input1').val(item.text);
return false;
}
return item.text;
}
});
});
</script>