本文介绍了如何清除文本字段焦点上的文本字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
< input name =nametype =text我想清除文本字段。 id =input1size =30maxlength =1000value =输入邮政编码或区域onfocus ==this.value =''/>
解决方案
为此,您需要使用脚本语言,可能是javascript。这里有一个例子
< input type ='text'value'Some text'onclick ='javascript:this.value = '/>
希望这会有所帮助。
编辑:
为了满足大卫在这里所要解释的是第二个例子,以防你正在寻找的东西
< script type ='javascript'>
var clear = true;
函数clear(obj)
{
if(clear)
{
obj.value ='';
clear = false;
}
}
< / script>
< input type ='text'value'Some text'onfocus ='clear(this);'/>
I want to clear the text field when the user clicks on that
<input name="name" type="text" id="input1" size="30" maxlength="1000" value="Enter Postcode or Area" onfocus=="this.value=''" />
解决方案
To do this you will need to use a scripting language, probably javascript. Here an example
<input type='text' value'Some text' onclick='javascript: this.value = ""' />
Hope this helps.
Edit:
To meet what David is explain here is a second example in case that is what you are looking for
<script type='javascript'>
var clear = true;
function clear(obj)
{
if(clear)
{
obj.value = '';
clear = false;
}
}
</script>
<input type='text' value'Some text' onfocus='clear(this);' />
这篇关于如何清除文本字段焦点上的文本字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!