In the JavaScript implementation text box, the background image disappears after the focus is obtained by default.
This example describes how to remove the background image after the focus is obtained by default in the JavaScript implementation text box. Share it with you for your reference. The details are as follows:
Html code:
?
1 2 3 4 5 6 7 8 9 |
<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! "Class =" submit" Style = "cursor: pointer;"/> </Div> </Form> |
JS Code:
?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
<Script type = "text/javascript" language = "javascript"> (Function (){ Var id = document. getElementById ('search-form '); If (id & id.txt Input ){ Var name = id.txt Input; Var unclicked = function (){ If (name. value = ''){ Name. style. background = '# FFFFFF url (images/googbg.png) left no-repeat '; } }; Var clicked = function (){ Name. style. background = '# ffff '; }; Name. onfocus = clicked; Name. onblur = unclicked; Unclicked (); } })(); </Script> |
I hope this article will help you design javascript programs.