In the JavaScript implementation text box, the background image disappears after the focus is obtained by default. In the javascript text box
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:
<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:
<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 design javascript programs.