js模拟自动完成效果

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>自动完成模拟</title>
<style type="text/css">
#main
{
 position:absolute;
 margin:20px;
 

}
#top,#bottom
{
 width:200px;
 border:1px #0066FF solid;
 position:relative;
 top:10px;
 left:10px;
 display:block;
}
#top input
{
 border:1px #666666 solid;
 width:150px;
 height:20px;
 background-color:#999999;

}
#bottom
{
visibility:hidden;
display:block;
position:relative;
top:15px;
left:10px;
}
</style>
<script type="text/javascript" >
function Kdown()
{
 var ev=window.event;
 var value=document.getElementById(ev.srcElement.id).value;
 if(value=="a")
 {
  bottom.style.visibility="visible";
  var str="aaa<br/>abc<br/>acd<br/>admkj<br/>";
  bottom.innerHTML=str;
 }
}
</script>
</head>

<body>
<div id="main">
 <div id="top">
  <input type="text" id="id1" onkeyup="Kdown()" />
 </div>
 <div id="bottom">
 </div>
</div>
</body>
</html>

posted @ 2009-10-27 14:34  坐看风起  阅读(263)  评论(0编辑  收藏  举报