HTML如何使用javascript清除输入? [英] HTML how to clear input using javascript?
本文介绍了HTML如何使用javascript清除输入?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有这个 INPUT,每次我们点击里面都会清除.
I have this INPUT, it will clear everytime we click inside of it.
问题:我只想清除 value = exemlo@exemplo.com
The problem: I want to clear only if value = exemplo@exemplo.com
<script type="text/javascript">
function clearThis(target) {
target.value= "";
}
</script>
<input type="text" name="email" value="exemplo@exemplo.com" size="30" onfocus="clearThis(this)">
有人可以帮我做这件事吗?我不知道如何比较,我已经尝试过但没有成功.
Can someone help me to do this? I don't know how to compare, I already tried but no success.
推荐答案
<script type="text/javascript">
function clearThis(target) {
if (target.value == 'exemplo@exemplo.com') {
target.value = "";
}
}
</script>
这真的是您要找的吗?
这篇关于HTML如何使用javascript清除输入?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文