文本框初始文字的设置 请问,怎样用代码实现文本框里初始的数字为灰色,之后输入的数字为黑色。谢谢 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 <asp:TextBox ID="txtPName" CssClass="grayColor"onfocus="this.className='blackColor'" Text="defaultText" runat="server"></asp:TextBox>也可以给textbox加focus事件,在里面修改样式 在onfecus时更新style和LZ说的有什么区别? 我用dreamweaver做的,看不懂asp那个代码啊…… 一个文本框内的资斧字符只能有一种颜色。初始设定为灰色 然后添加事件 onfocus="this.color='black';" LZ 能否表达清楚点,你的意思是 文本框txta的初始值“111”是灰色而新输入的值“222”是给色,而且结果是“111222”么? <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Insert title here</title> <style> #_input { color: #aaa; border: 1px solid #CC0000; padding: 1px; } </style> </head> <body> <input type="text" name="textName" value="aa" id="_input"> </body> <script language="javascript"> var s = document.getElementById("_input"); s.onfocus = function(){ if (this.value == this.defaultValue) this.value = '' }; s.onblur = function(){ if (/^\s*$/.test(this.value)) { this.value = this.defaultValue; this.style.color = '#aaa' } } s.onkeydown = function(){ this.style.color = '#333' } </script></html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Demo</title> <script type="text/javascript" src="jquery-1.4.min.js"></script> <script type="text/javascript"> $(document).ready(function(){ $("#txtName").focus(function(){ $(this).css({color:"Black"}); }); }); </script> </head> <body> <input type="text" value="请输入数字" id="txtName" style="color:Gray'"/> </body></html> js怎么获取背景图片呢?用这个返回的是空,不知道是怎么回事 求教win7下的一个bug问题,js不能正常显示 js主题皮肤更换 javascript编写广告控件 js循环 ◆◆◆◆◆ 更新数据岛数据的问题 怎么屏蔽键入空格?(Netscape) 求救:这个效果谁能实现?(地图查询) 右键的事件是什么? 请教2个问题: 请教一个js函数如何理解呢?(是dedecms中的初级模板代码) js多个checkbox赋值
<asp:TextBox ID="txtPName" CssClass="grayColor"
onfocus="this.className='blackColor'" Text="defaultText" runat="server"></asp:TextBox>也可以给textbox加focus事件,在里面修改样式
初始设定为灰色
然后添加事件 onfocus="this.color='black';"
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<style>
#_input {
color: #aaa;
border: 1px solid #CC0000;
padding: 1px;
}
</style>
</head>
<body>
<input type="text" name="textName" value="aa" id="_input">
</body>
<script language="javascript">
var s = document.getElementById("_input");
s.onfocus = function(){
if (this.value == this.defaultValue)
this.value = ''
};
s.onblur = function(){
if (/^\s*$/.test(this.value)) {
this.value = this.defaultValue;
this.style.color = '#aaa'
}
}
s.onkeydown = function(){
this.style.color = '#333'
}
</script>
</html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Demo</title>
<script type="text/javascript" src="jquery-1.4.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("#txtName").focus(function(){
$(this).css({color:"Black"});
});
});
</script>
</head>
<body>
<input type="text" value="请输入数字" id="txtName" style="color:Gray'"/>
</body>
</html>