/ Published in: JavaScript

Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
// A simple, lightweight, on-the-fly script to handle the clearing and resetting of a text field var searchField = document.getElementById('search'); var defaultText = searchField.value; searchField.onfocus = function(){ if( searchField.value == defaultText ){ searchField.value = ''; } }; searchField.onblur = function(){ if( searchField.value == '' ){ searchField.value = defaultText; } };
Comments
