/ Published in: JavaScript

This requires jQuery. The script checks to see if default text is present in a text field on focus. If it is, then it clears the text. Otherwise, it leaves user entered text intact. This is normally used for a search box.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
$("#searchbox").focus(function () { if ($("#searchbox").val() == "Blah Blah Blah") { $("#searchbox").val(""); } });
Comments
