<input type="text" name="txt_name" id="txt_name" value="1" onfocus="txtFoc()" onblur="txtOnb()" /><input type="submit" value="搜索" onclick="return nClick()" />
function txtFoc(){
var con=document.getElementById("txt_name");
if(con.value=="1")
{
con.value="";
}else
{
con.focus();
}
}
function txtOnb()
{
var tname=document.getElementById("txt_name").value;
想实现的是当鼠标离开焦点时..得到刚才传的值 然后赋值到text控件的value,而不是显示1..在线的帮忙 谢谢咯 }
</script>
function txtFoc(){
var con=document.getElementById("txt_name");
if(con.value=="1")
{
con.value="";
}else
{
con.focus();
}
}
function txtOnb()
{
var tname=document.getElementById("txt_name").value;
想实现的是当鼠标离开焦点时..得到刚才传的值 然后赋值到text控件的value,而不是显示1..在线的帮忙 谢谢咯 }
</script>
document.getElementById("txt_name").value = tname;
{
con.value="";
}
你这写的什么意思啊?
function txtFoc(){
var con=document.getElementById("txt_name").value;
if(con=="1")
{
con="";
}else
{
con.focus();
}
}
function txtOnb()
{
var tname=document.getElementById("txt_name").value;
想实现的是当鼠标离开焦点时..得到刚才传的值 然后赋值到text控件的value,而不是显示1..在线的帮忙 谢谢咯 }
</script>
{
var s=document.getElementById("txt_name").value;
if (s==1)
{
document.getElementById("txt_name").value="";
}
else
{
document.getElementById("txt_name").focus();
}
}说实话,还真没明白嘛意思。这是输入1的话,置空。。
var a = document.getElementById("ipt").value;
if (a == "1") {
document.getElementById("ipt").value = "";
}
}
function blur() {
var aa = document.getElementById("ipt").value;
if (aa == "") {
document.getElementById("ipt").value = "1";
}
}
<input id="ipt" value="1" onfocus="fucus()" onblur="blur()" type="text" />
[/Quotetext 默认值是1 然后传了一值 是2(值都可以) 想实现的就是当我失去焦点时...... text就会变成2 也不是这个默认值1
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title> <script type="text/javascript">
function txtFoc() {
var con = document.getElementById("txt_name");
if (con.value == "通过") {
con.value = "中国";
} else {
con.focus();
}
}
function txtOnb() {
var tname = document.getElementById("txt_name").value;
document.getElementById("txt_name").value = tname;
document.getElementById("txt_name").focus();
return false;
}
</script></head>
<body>
<form id="form1" runat="server">
<div>
<input type="text" name="txt_name" id="txt_name" value="通过" onmouseout="txtFoc()" onblur="txtOnb()" />
<input type="button" value="搜索" onclick="return txtFoc()" />
</div>
</form>
</body>
</html>
<!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=utf-8" />
<title>水印案例</title>
<script>
function $(id)
{
return document.getElementById(id);
}
function b()
{
$("txt1").value="";
}
function c()
{
$("txt1").value="请输入用户名";
}
</script>
</head><body>
<input type="text" id="txt1" onfocus="b()" onblur="c()"/>
</body>
</html>
最简单的