<html>
<head>
<title>鼠标点击文本框后,里面的文字就消失或全选中</title>
</head>
<body>
鼠标点击文字消失:<input name="textfield" style="color:#CCC;" type="text" value="点击文字消失" size="12" onclick="value='';focus()" />
<br/> <br/>
鼠标点击文字选中:<input name="textfield" type="text" value="点击文字选中" size="12" onclick="focus();select()" />
<br/><br/>
<input name="key" type="text" id="key" value="关键词" size="30" onmouseover=this.focus();this.select(); onclick="if(value==defaultValue){value='';this.style.color='#000'}" onBlur="if(!value){value=defaultValue;this.style.color='#999'}" style="color:#999" />
</body>
</html>
<head>
<title>鼠标点击文本框后,里面的文字就消失或全选中</title>
</head>
<body>
鼠标点击文字消失:<input name="textfield" style="color:#CCC;" type="text" value="点击文字消失" size="12" onclick="value='';focus()" />
<br/> <br/>
鼠标点击文字选中:<input name="textfield" type="text" value="点击文字选中" size="12" onclick="focus();select()" />
<br/><br/>
<input name="key" type="text" id="key" value="关键词" size="30" onmouseover=this.focus();this.select(); onclick="if(value==defaultValue){value='';this.style.color='#000'}" onBlur="if(!value){value=defaultValue;this.style.color='#999'}" style="color:#999" />
</body>
</html>
本文介绍了一种使用HTML实现的文本框交互效果,包括点击文本框时清除默认提示文字及全选文本的功能。通过简单的HTML属性设置即可实现这些实用的效果。
611

被折叠的 条评论
为什么被折叠?



