首页 > 代码库 > 点击输入关键字 下拉列表

点击输入关键字 下拉列表

<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>请输入关键字</title>
</head>

<body>
<style>
ul,li{list-style:none;}
</style>

<script language="JavaScript">
function show(){
var val = document.getElementsByTagName("input");
var oUl = document.getElementsByTagName("ul");
if (val[0].value !=‘‘)
{
val[0].value =http://www.mamicode.com/‘‘;
oUl[0].style.display="block";

}
}

function hide(){
var val = document.getElementsByTagName("input");
var oUl = document.getElementsByTagName("ul");
if (val[0].value =http://www.mamicode.com/=‘‘)
{
val[0].value ="http://www.mamicode.com/请输入关键字";
oUl[0].style.display="none";
}
}

</script>

<input value="http://www.mamicode.com/请输入关键字"
onfocus="show()"
onblur="hide()" />

<ul style="display:none;">
<li>标题1</li>
<li>标题2</li>
<li>标题3</li>
<li>标题4</li>
</ul>

</body>
</html>