-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtry.html
More file actions
56 lines (54 loc) · 1.4 KB
/
try.html
File metadata and controls
56 lines (54 loc) · 1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>jQuery跨域</title>
<style>
input{width:600px;height:30px;border:1px solid blue;margin-top:100px;margin-left:300px;}
li{list-style:none;background:lightgoldenrodyellow ;width:600px;height:30px;display:none;}
ul{margin-left:260px;}
.aa{display:block;}
</style>
</head>
<body>
<input type="text">
<ul>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
</ul>
</body>
</html>
<script src="jquery.js "></script>
<script>
$(function(){
$("input").keyup(function(){
$.ajax({
type:"get",
data:"wd="+$(this).val(),
dataType:"jsonP",
url:"http://suggestion.baidu.com/su",
success:function(data){
}
});
});
});
var baidu={
sug:function(data){
for(var i=0;i<10;i++){
document.getElementsByTagName ("li")[i].setAttribute("class","aa");
document.getElementsByTagName ("li")[i].innerText =data.s[i];
if($("input").val().length>8||$("input").val().length==0){
$("li").removeAttr("class")
}
}
}
}
</script>