百度搜索智能提示案例jsonp
2016-11-28 13:43
507 查看
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>百度下拉_sug-jquery</title> <script src="jquery-1.11.3.js"></script> <style> #sug{ position: absolute; left: 50%; margin-left: -150px; margin-top: 200px; width: 300px; background: lightGreen; height: 40px; text-align: center; } #sug input{ margin-top: 10px; } #list{ position: absolute; left: 50%; top:50px; width: 200px; margin-left: -150px; margin-top: 200px; height: auto; background: lightBlue; } #list ul{ padding-left: 0px; margin: 0px; } #list ul li{ background: lightGray; line-height: 30px; list-style: none; padding-left: 10px; margin-top: 0px; cursor: pointer; } #list ul li.on{ background: lightGreen; } </style> </head> <body> <div id="sug"> <div> <input type="text" id="keyWord" autocomplete=off> <input type="button" value="百度一下" id="btn"> </div> </div> <div id="list"> </div> <script> $(function(){ $("#keyWord").keyup(function(e){ var kd = $("#keyWord").val(); var url = 'https://sp0.baidu.com/5a1Fazu8AA54nxGko9WTAnF6hhy/su?wd='+kd; querySUG(url); }); }); function querySUG(url){ document.getElementById(' 4000 list').innerHTML = ''; $.ajax({ type : "get", async: true, url : url, dataType : "jsonp", jsonp: "cb", jsonpCallback:"callback", success : function(data){ var ul = $("<ul></ul>"); $.each(data.s,function(i,element){ var e = $("<li></li>").append(element); $(ul).append(e); }); $("#list").append(ul); }, error:function(){ console.log('fail'); } }); } </script> </body> </html>
相关文章推荐
- 使用jsonp跨域调用百度js实现搜索框智能提示,并实现鼠标和键盘对弹出框里候选词的操作【附源码和在线测试地址】
- 百度搜狗等搜索引擎智能提示(JSONP跨域实现自动补全搜索建议)
- 利用jsonp跨域调用百度js实现搜索框智能提示
- 使用jsonp跨域调用百度js实现搜索框智能提示,并实现鼠标和键盘对弹出框里候选词的操作【附源码】
- 使用jsonp跨域调用百度js实现搜索框智能提示(转)
- 百度等搜索引擎智能提示(JSONP跨域实现自动补全搜索建议)
- 百度搜狗等搜索引擎智能提示(JSONP跨域实现自动补全搜索建议)
- 使用jsonp跨域调用百度js实现搜索框智能提示,并实现鼠标和键盘对弹出框里候选词的操作【附源码和在线测试地址】
- 百度搜狗等搜索引擎智能提示(JSONP跨域实现自动补全搜索建议)
- 百度搜索框智能提示案例jsonp
- 使用jsonp跨域调用百度js实现搜索框智能提示,并实现鼠标和键盘对弹出框里候选词的操作【附源码和在线测试地址】
- jQuery 插件 仿百度搜索框智能提示 调用简单!
- Winform实现百度搜索框智能提示功能( C# )
- jquery php 百度搜索框智能提示效果
- 带智能提示的百度搜索框 —— 新:JS压缩更精简
- Servlet+Ajax实现简易的仿百度搜索框智能提示
- C# 实现百度搜索框智能提示功能
- jQuery 插件仿百度搜索框智能提示(带Value值)
- 各大搜索引擎智能提示API(JSONP跨域实现自动补全搜索建议)
- jquery php 百度搜索框智能提示效果