<script src="https://lf6-cdn-tos.bytecdntp.com/cdn/expire-1-M/jquery/2.2.4/jquery.js" type="application/javascript"></script>
<style>
.show {
width: 300px;
height: 200px;
border: 2px solid blue;
display: block;
}
</style>
</head>
<body>
<input type="text" />
<ul class="show"></ul>
<script>
// http://suggestion.baidu.com/su?wd=" + this.value + "&cb=?
let search = document.querySelector("input");
let show = document.querySelector(".show");
search.oninput = function () {
// 发请求
$.getJSON("http://suggestion.baidu.com/su?wd=" + this.value + "&cb=?",function(res){
if(res.s.length){
console.log(res.s);
show.innerHTML = ""
res.s.forEach(ele=>{
show.innerHTML += `<li>${ele}</li>`
})
}
})
};
</script>