提示什么?
<input type="text">
<input type="text" onfocus="this.value='请输入密码:'"/>
这样??
<input type="text">
<input type="text" onfocus="this.value='请输入密码:'"/>
这样??
解决方案 »
- js 复制本地文件到系统临时文件夹问题
- 用JS换屏效果就报错(对象不支持此方法),不用此效果就正常。。。。。。
- 页面自动刷新的问题
- 为什么使用IE不显示地图图片,Firefox可以显示正常那
- 跨域iframe问题?
- 弹出页时,父页回到顶部的问题
- 30分求一个超级无敌简单菜鸟javascript语法问题!在线等,送分题!!!!
- 有没有办法让一个页面跳到所有窗口的最前面?很难!我认为!大家帮忙!来人有分!
- JS中判空的方法有哪些?
- javascript咋判断一个字符串是不是数字?
- 在input文本框中能否加入像在<img>中加alt一样显示出的浮动提示框。
- javascript是否能以二进制的模式打开文件??????
function cls(){
//捕获触发事件的对象,并设置为以下语句的默认对象
with(event.srcElement)
//如果当前值为默认值,则清空
if(value==defaultValue) value=""
}
function res(){
//捕获触发事件的对象,并设置为以下语句的默认对象
with(event.srcElement)
//如果当前值为空,则重置为默认值
if(value=="") value=defaultValue
}
</script>
<input value="填写您的昵称" onfocus="cls()" onblur="res()">
<input value="填写您的生日(1900-01-01)" onfocus="cls()" onblur="res()">
--------------------------------------
请问怎样把上面改成文本框默认为空。插入光标是有提示,光标移出时清空文本框,
<head>
<title>Untitled</title>
<script>
function cls(){
//捕获触发事件的对象,并设置为以下语句的默认对象
with(event.srcElement)
//如果当前值为默认值,则清空
//if(value==defaultValue) value=""
if(value=="") value=defaultValue
}
function res(){
//捕获触发事件的对象,并设置为以下语句的默认对象
with(event.srcElement)
//如果当前值为空,则重置为默认值
//if(value=="") value=defaultValue
if(value==defaultValue) value=""
}
</script>
</head><body>Hello World!
<Form>
<input value="填写您的昵称" onfocus="cls()" onblur="res()">
<input value="填写您的生日(1900-01-01)" onfocus="cls()" onblur="res()">
</Form>
</body>
</html>
<input name=haha2 type=text>
<input name=haha type=text onfocus="document.getElementById('mytips').style.visibility='visible';" onblur="document.getElementById('mytips').style.visibility='hidden';">
<div id=mytips style="position:absolute;background-color:#ff0000;width:121;visibility:hidden;height:16;left:200; top:5">提示</div>
改了你的函数,<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><html>
<head>
<title>Untitled</title>
<script>
function cls(){
with(event.srcElement)
if(value==name) value=""
}function res(){
with(event.srcElement)
if(value=="") value=name
}
</script>
</head><body>
Hello World!
<Form>
<input type="textbox" value="" onfocus="res()" onblur="cls()" size="40" name="填写您的昵称"> <br>
<input type="textbox" value="" onfocus="res()" onblur="cls()" size="40" name="填写您的生日(1900-01-01)"> <br>
</Form>
</body>
</html>添加了textbox的name属性。你好象就是困惑在这里。我测试通过了,
测试环境:
2000Pro
IE6.0
<head>
<title>Untitled</title>
<script>
function cls(){
with(event.srcElement)
if(value==name) value=""
}function res(){
with(event.srcElement)
if(value=="") value=name
event.srcElement.select();
}
</script>
</head><body>
Hello World!
<Form>
<input type="textbox" value="" onfocus="res();" onblur="cls()" size="40" name="填写您的昵称"> <br/>
<input type="textbox" value="" onfocus="res()" onblur="cls()" size="40" name="填写您的生日(1900-01-01)"> <br/>
</Form>
</body>
</html>你想要鼠标的,添加onmousedown事件就可以了。测试环境:
2000Pro
IE6.0