This example describes the method by which the default display background picture in the JavaScript implementation text box disappears after the focus has been obtained. Share to everyone for your reference. Specifically as follows:
HTML code:
<form name= "Searchform" id= "Search-form" >
<div>
<b>Search</b>
<input type= "Text" name= "Txtinput" title= "Enter the terms you wish to search for."/> <input type= "
Submit" value= "go!" C Lass= "Submit"
style= "cursor:pointer;"/>
</div>
</form>
JS Code:
<script type= "Text/javascript" language= "JavaScript" >
(Function () {
var id = document.getElementById (' Search-form ');
if (ID && id.txtinput) {
var name = Id.txtinput;
var unclicked = function () {
if (Name.value = = ') {
name.style.background = ' #FFFFFF url (images/googbg.png) left No-repeat ';
}
;
var clicked = function () {
name.style.background = ' #ffffff ';
};
Name.onfocus = clicked;
Name.onblur = unclicked;
Unclicked ();
}
}) ();
</script>
I hope this article will help you with your JavaScript programming.