如何用div做一个特效:

来源:百度知道 编辑:UC知道 时间:2024/05/26 15:30:18
请教,如何用div做:在文本域里输入一个字,下方便出现以前包含这个字的所有记录?
问题有点不明确,重说明一下:
就像在百度搜索框里点一下,下面就有个框框,如何用div实现,光标定在文本域,下面的框框便出现,并不要求框框里出现记录,只要有框框出现。请指教

code like:

<input type="text" name="inputField" id="inputField" onchange="handleReq()"/>
<div display="none" id="hintDiv"></div>

In your javascript section, write a function like
function handleReq(){
if (document.getElementById("hintDiv").display == "block")
document.getElementById("hintDiv").display = "none";
var v = document.getElementById("inputField").value;
var respond = /*Here you send v to server and get Respond*/
document.getElementById("hintDiv").display = "block";
document.getElementById("hintDiv").innerHTML = /*Here is your hint text*/
}

Above is some example for your question. The essential part is to HIDE the hint Div before request, and SHOW it when respond is received and well parsed.

For CSS part, you may need