Posted By

rumremix on 05/27/11


Tagged

javascript search default jquery text box change sharepoint 2010


Versions (?)

change the default search box text in SharePoint 2010 using JQuery


 / Published in: JavaScript
 

Use whatever is needed to select the input box. $('#searchBoxOuter td.ms-sbcell input') reflects some custom master page html I have so I used that.

  1. $(function() {
  2.  
  3. var theSearchBox = $('#searchBoxOuter td.ms-sbcell input');
  4. var defaultSearchText = "Search this site";
  5. var preferredSearchText = "Search my custom site name";
  6.  
  7. theSearchBox.val(preferredSearchText); //replace the text initially
  8.  
  9. theSearchBox.blur(function() { //replace the text when the search box loses focus and no value entered
  10. if ($(this).val().indexOf(defaultSearchText) > -1)
  11. $(this).val(preferredSearchText);
  12.  
  13. });
  14.  
  15.  
  16. });

Report this snippet  

You need to login to post a comment.