日期:2014-05-16 浏览次数:20517 次
<html>
<body>
<p>天气查询:</p>
<form action="/weather/" method="get">
<input type="text" name="weather_search" rows="2" cols="40"></input>
<input type="submit" value="Search">
</form>
</body>
</html>
<!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=utf-8" />
<title>autocomplete测试</title>
<link rel="stylesheet" type="text/css" href="jquery-ui-1.10.4.custom/css/ui-lightness/jquery-ui-1.10.4.custom.min.css" />
<style>img{width:30px;height:30px;}</style>
<script src="jquery-ui-1.10.4.custom/js/jquery-1.10.2.js"></script>
<script src="jquery-ui-1.10.4.custom/js/jquery-ui-1.10.4.custom.min.js"></script>
</head>
<body>
<input type="text" id="autocompleteTest" autocomplete="off" name="q" value="autocomplete测试" onfocus="if(this.value=='autocomplete测试'){this.value='';}" onblur="if(this.value=='') {this.value = 'autocomplete测试';}" class="ui-autocomplete-input">
<script type="text/javascript">
var json=[{label:"aaa",pictureurl:"http://www.baidu.com/img/bdlogo.gif",url:"http://www.baidu.com"},{label:"bbbbb",pictureurl:"http://i1.sinaimg.cn/dy/deco/2013/0329/logo/LOGO_1x.png",url:"http://www.sina.com"}];
$(function () {
$('#autocompleteTest').autocomplete({
delay: 500,
minLength: 1,
source: json,//这里为了测试,直接定义了一个json对象,实际应用中通常是一个url地址
select: function( event, ui ) {
$("#autocompleteTest").val(ui.item.label);
//location=(ui.item.url);
return false;
}
}).data("ui-autocomplete")._renderItem = function( ul, item ) {
var t = item.label;
return $("<li></li>")
.data("item.autocomplete", item)
.append("<a><img src='" + item.pictureurl + "'>" + t + "</a>"
).appendTo(ul);
};
});
&