User:Nachteule/SearchDefaultText.js

From Uncyclopedia, the content-free encyclopedia
Jump to navigation Jump to search

Note: After saving, you have to bypass your browser's cache to see the changes.

  • Internet Explorer: hold down the Ctrl key and click the Refresh or Reload button, or press Ctrl+F5.
  • Firefox: hold down the Shift key while clicking Reload; alternatively press Ctrl+F5 or Ctrl-Shift-R.
  • Opera, Konqueror and Safari users can just click the Reload button.
  • Chrome: press Ctrl+F5 or Shift+F5
jQuery(document).ready(function() {
     //
     // then put "search" in input field
     //
    jQuery("#searchInput").val("search");
     //
     // font-color grey instead of black
     //
    jQuery("#searchInput").css("color", "#888");
     //
     // if we click that field, "search" hast to disappear
     //
    jQuery("#searchInput").bind("focus", function(event) {
    jQuery("#searchInput").val("");
    jQuery("#searchInput").css("color", "");
    });
     //
     // as soon as we click something outside that box, put "search" in there again ...
    jQuery("#searchInput").bind("blur", function(event) {
     //
     // ... but only, when nobody has already typed something in that field
     //
    if (jQuery("#searchInput").val() === "") {
      jQuery("#searchInput").val("search");
      jQuery("#searchInput").css("color", "#888");
      }
    });
 })