復(fù)制代碼 代碼如下:
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>成為焦點(diǎn)時(shí)清除文本框內(nèi)容</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" value="清除文本框一的內(nèi)容"/><br/>
文本框二:<input type="text" value="清除文本框二的內(nèi)容"/><br/>
文本框三:<input type="text" value="清除文本框三的內(nèi)容"/>
</body>
</html>
新聞熱點(diǎn)
疑難解答
圖片精選