百度搜索框

 <!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)
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值