日期:2014-05-18  浏览次数:20485 次

文本框的使用
我看有些网站上的一些文本框中有提示文字,当你单击去输入内容时提示文字没有了,不知这是用什么功能实现。哪个知道以解释一下,若有实例把代码贴出来更好!谢谢了

------解决方案--------------------
1.比如:<input ID="txtkeyword" name="txtkeyword" onfocus="iKeyword(this,1)" onblur="iKeyword(this,2)" value="请输入..." type="text" />
2.javaScript函数如下:
function iKeyword(obj,type){
var init="请输入文章主题...";
switch(type){
case 1:
if(obj.value==init){obj.value="";}
obj.style.cssText="color:black";
break;
case 2:
if(obj.value==""){
obj.value=init;
obj.style.cssText="";
}else{
obj.style.cssText="color:black";
}
break;
}
}
------解决方案--------------------
探讨
1.比如: <input ID="txtkeyword" name="txtkeyword" onfocus="iKeyword(this,1)" onblur="iKeyword(this,2)" value="请输入..." type="text" />
2.javaScript函数如下:
function iKeyword(obj,type){
var init="请输入文章主题...";
switch(type){
case 1:
if(obj.value==init){obj.value="";}
obj.style.cssText="color:black";
break;
case 2:
if(obj.value==""){
obj.value=init;
obj.style.cssText="";
}else…