用Button控件编写段JAVASCRIPT 来实现清除HTNL:text的默认值

来源:百度知道 编辑:UC知道 时间:2024/06/18 10:35:25
用Button控件编写段JAVASCRIPT 来实现清除HTNL:text的默认值

<input type="text" id="TextBox1" value="123">
<input type="button" onclick="fnclear()" id="bt" value="清空按钮">
<script>
function fnclear(){
document.getElementById('TextBox1').value="";
}
</script>

吧这段代码直接复制到body里

可以用如下方式实现:
<html>
<head>
<meta http-equiv=Content-Type content="text/html;charset=uft-8">
<script language="javascript">
function ClearAllText()
{
var TextBox = document.getElementsByTagName("INPUT");
for(var Count=0;Count<TextBox.length;Count++)
{
if(TextBox[Count].type.toUpperCase() == "TEXT")
{
TextBox[Count].value = "";
}
}
//for循环用于将画面所有的文本框都