<!doctype html><html><head> <meta charset="UTF-8"> <title>Document</title> <style type="text/css"> #sea{ width: 300px; height: 35px; border: solid #666 1px; padding-left: 5px; } #ul1,li,input{ padding: 0; margin: 0; list-style: none } #ul1{ border: solid #666 1px; width: 305px; margin-top: -2px; display: none; } #ul1 li a{ line-height: 35px; display: block; width: 300px; padding-left: 5px; text-decoration: none; color: black; } </style> <script type="text/javascript"> function maiov(data){ var oUl=document.getElementById('ul1') var html=" "; for (var i = 0; i < data.s.length; i++) { html += '<li><a target="_blank" href="http://www.baidu.com/s?wd='+data.s[i]+'">'+ data.s[i] +'</a></li>'; }; oUl.style.display="block" oUl.innerHTML=html; } window.onload=function(){ var s=document.getElementById('sea'); var oLl=document.getElementById('ul1').getElementsByTagName('li') s.onkeyup=function(){ var oScript=document.createElement("script") oScript.src='http://suggestion.baidu.com/su?wd='+this.value+'&cb=maiov' document.body.appendChild(oScript); }; var index=-1; document.onkeydown=function(event){ if(event.keyCode===40){ for (var i = 0; i < oLl.length; i++) { oLl[index].style.backgroundColor="red" }; } } } </script> </head><body> <input id="sea" type="text"> <ul id="ul1"> </ul> </body></html>
添加回答
举报
0/150
提交
取消