JS检测 textarea 的问题教程
<form method="get" action="#" >
<div class="iciba_left"><a href="" target="_blank"><img src="themes/skin/iciba/iciba.gif" /></a></div>
<div class="iciba_top_main">
<textarea name="iciba_doc" id="iciba_doc"></textarea>
</div>
<div class="iciba_right">
<input name="iciba_go" type="submit" value="" />
</div>
</form>
<script>
if(document.getElementById('iciba_doc').value==''){
document.getElementById('iciba_doc').value=='请输入要查询的英文单词或句子,按CTRL+ENTER';
}
</script>
我这样做的检测 为什么没反应啊
//输入框的默认值
function def_value(id,msg){
if(document.getElementById(id).value==""){
document.getElementById(id).value=msg;
}
document.getElementById(id).onclick=function(){
if(document.getElementById(id).value==msg){
document.getElementById(this.id).value="";
}
}
document.getElementById(id).onblur=function(){
if(document.getElementById(id).value==''){
document.getElementById(this.id).value=msg;
}
}
}
调用方法
<script>
window.onload=function(){
def_value('iciba_doc','请输入要查询的英文单词或句子,按CTRL+ENTER');
};
</script>