当文本框获取焦点时弹出一个层当失去焦点时层自动隐藏
这个怎么写求助???????????????
这个怎么写求助???????????????
解决方案 »
- jquery.post()的问题,怎么更改网络框架给出的例子
- 寻找jquery,js高手 帮忙解决问题
- 内面内嵌入的框架页面如何读取外面页面的URL?在线等,谢谢~`
- prototype.js+XML+XSLT+c# 很好很强大,Dojo,ext很大很垃圾,欢迎加入Web技术群:50693277
- removeChild方法,参数无效???
- 用deleteRow删除表格中的行,怎么才能得到当前行的行号?
- 如何从一个html文件直接传递值到jsp文件,谢谢
- 关于下拉菜单联动的问题?
- javascript中取小時用那個函數,急用,謝謝!
- 关于下载TXT文件
- object 动态添加属性
- 求教关于jQuery的一个小问题 哪位大哥帮忙看一下
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>show div and move on div</title>
<style type="text/css">
.floatPic{
display:none;
position:absolute;
width:200px;
height:100px;
boder:1px;
background:lightblue;
}
</style>
<script type="text/javascript">
var fhide=true;
function ShowFloatPic(obj,evt)
{
fhide=false;
var div=document.getElementById("divinfo");
div.innerHTML="";
var itext=obj.value;
var tnode=document.createTextNode(itext,true);
div.appendChild(tnode);
div.style.display="block";
div.style.left=evt.clientX+30;
div.style.top=evt.clientY;
}
function prepareHide()
{
fhide=true;
setTimeout("tryHide()",500);
//setTimeout(function(){if (fhide){HideFloatPic();}},500);
}
function tryHide()
{
if (fhide)
{
HideFloatPic();
}
}
function HideFloatPic()
{
var div=document.getElementById("divinfo");
div.style.display="none";
}
function cancelHide()
{
fhide=false;
}
</script>
</head><body style="margin:0;padding:0">
<input type="text" onfocus="ShowFloatPic(this,event)" onblur="prepareHide()" value="文本框" />
<div id="divinfo" class="floatPic" onmouseover="cancelHide();" onmouseout="HideFloatPic();" ></div>
</body></html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>TEST</title>
<style type="text/css">
body,td,div,input,fieldset,legend{font-family:Verdana; font-size:12px; color:#333333; font-weight:normal;}
td{line-height:20px;}
a:link,a:visited{font-family:Verdana; font-size:12px; color:#330099; font-weight:normal; text-decoration:none;}
a:hover,a:active{font-family:Verdana; font-size:12px; color:#FF6600; font-weight:normal; }
span{font-family:Verdana; font-size:12px; color:red; font-weight:normal; display:block; margin:0px 10px;}
#div01{display:none;}
</style>
</head>
<script type="text/javascript" >
function $(id){
return "string" == typeof(id) ? document.getElementById(id) : id;
}function chan(divID,flag){
var oid=divID;
if(oid=="") return;
var o=$(oid);
var f=flag.toLowerCase();
if(f=="hide") o.style.display="none";
else o.style.display="block";
}
</script>
<body>
<input name="inputx01" type="text" value="点击这里试看" onfocus="chan('div01','show');" onblur="chan('div01','hide');" />
<input name="inputx02" type="text" value="value02" />
<div id="div01" style="border:1px solid red; width:300px;">
Tip: your massege...
</div></body>
</html>
onblur是失去焦点时触发
文本框:<input type="text" style="width:103px" name="year" id="timeid" value="" onfocus="showTable(this,this.id)" onblur="closeTable();" >
js:var idtt;
document.writeln("<div id='mydate' style='position:absolute;width:160px;'></div>");
function closeTable(){
document.getElementById(mydate).style.display="none";
}
function showTable(InputBox,idt){
idtt=idt;
var x, y;
var DivContent;
var o = InputBox;
//显示的位置
x = o.offsetLeft;
y = o.offsetTop;
while (o = o.offsetParent) {
x += o.offsetLeft;
y += o.offsetTop;
}
document.all.mydate.style.left = x + 2;
document.all.mydate.style.top = y + 20;
document.all.mydate.style.visibility = "visible";