当某个文本框成为焦点时即清除文本框内容

时间:2014-04-28    点击:120   
复制代码 代码如下:

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>成为焦点时清除文本框内容</title>
<script>
window.onload = initAll;

function initAll(){
var clearText = document.getElementsByTagName("input");
for (var i=0; i<clearText.length; i++){
clearText[i].onfocus = function ( ){
this.value = "";
}
}
}
</script>
</head>

<body>
文本框一:<input type="text" name="text" id="clearText1" value="清除文本框一的内容"/><br/>
文本框二:<input type="text" name="text" id="clearText2" value="清除文本框二的内容"/><br/>
文本框三:<input type="text" name="text" id="clearText3" value="清除文本框三的内容"/>
</body>
</html>
javascript中使用正则计算中文长度的例子
一个简单的Node.js异步操作管理器分享
IE浏览器中图片onload事件无效的解决方法
javascript的创建多行字符串的7种方法
Javascript实现的常用算法(如冒泡、快速、鸽巢、奇偶等)
> 返回     
地址:上海市普陀区胶州路941号长久商务中心 电话: QQ:
© Copyright 2012 上海网络 Product All Rights Reserved