<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title>百度搜索</title>
<style>
.block{
width: 500px;
height: 40px;
border:1px solid black;
margin: auto;
position: absolute;
top: 0;
bottom: 0;
left:0;
right:0;
}
.block>input{
width:385px;
height:38px;
border-style: none;
outline:none;
font-size: 18px;
padding-left: 15px;
}
.block span{
display: inline-block;
width: 100px;
height: 40px;
text-align: center;
background-color: #1b1fff;
font-size: 20px;
color:white;
position: absolute;
top:0;
line-height: 40px;
cursor:pointer;
}
.ullist{
background-color: #dcfff5;
font-size: 18px;
}
.ullist li{
list-style: none;
}
.ullist>li a{
text-decoration: none;
color: black;
font-weight: bolder;
}
.bj{
width: 400px;
height: 150px;
margin-top:150px;
margin-left: 450px;
}
.bj>img{
width: 400px;
height: 150px;
}
</style>
</head>
<body>
<div class="bj">
<img src="./image/bd_logo1.png" alt=""/>
</div>
<div class="block">
<input id="test" type="text"/><span id="btn">百度一下</span>
</div>
<script src="jquery-1.9.1.js"></script>
<script>
$(function(){
$("#test").on("keyup",function(e){
$.ajax({
method:"post",
data:{wd:$(this).val()},
url:"https://sp0.baidu.com/5a1Fazu8AA54nxGko9WTAnF6hhy/su?cb=sr",
dataType:"jsonp",
jsonpCallback:"sr",
success:function(data){
$(".ullist").remove();
var ul=$("<ul class='ullist'></ul>");
for(var i=0;i<data.s.length;i++){
$("<li><a href='https://www.baidu.com/s?wd="+data.s[i]+"'>"+data.s[i]+"</a></li>").appendTo(ul);
}
$(".block").append(ul);
}
})
});
$("#btn").on("click",function (){
location.href="https://www.baidu.com/s?wd="+$("#test").val();
});
});
</script>
</body>
</html>![在这里插入图片描述](https://img-blog.csdn.net/20181012220536164?watermark/2/text/aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80MzE3NjMzNw==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70)
百度搜索框
最新推荐文章于 2024-07-10 13:40:50 发布