Add default text to the search textfield

Public

</> CopyGet raw version
javascript
  1. (function ($) {
  2. Drupal.behaviors.mysiteSearch = {
  3. attach: function() {
  4. // Hide the search submit button.
  5. $('#block-search-form .form-submit').hide();
  6.  
  7. // Apply the default text to the search block's text
  8. // field.
  9. $('#block-search-form .form-type-textfield .form-text')
  10. // Widen textfield.
  11. .attr('size', 30)
  12. // Add default text options on blur.
  13. .blur(function () {
  14. $(this).attr('value', Drupal.t('Enter search query ...'))
  15. .click(function () {
  16. $(this).attr('value', '');
  17. $(this).unbind('click');
  18. });
  19. })
  20. // Trigger the blur event to set things up.
  21. .blur();
  22. }
  23. };
  24. }(jQuery));