<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title> Clear text box content when in focus </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>
Text box 1: <input type="text" name="text" id="clearText1" value=" Clear the contents of textbox 1 "/><br/>
Text box 2: <input type="text" name="text" id="clearText2" value=" Clear the contents of text box 2 "/><br/>
Text box 3: <input type="text" name="text" id="clearText3" value=" Clear the contents of text box three "/>
</body>
</html>