Return to Snippet

Revision: 46912
at May 27, 2011 10:38 by rumremix


Updated Code
$(function() {
 
var theSearchBox = $('#searchBoxOuter td.ms-sbcell input');
var defaultSearchText = "Search this site";
var preferredSearchText = "Search my custom site name";
  
theSearchBox.val(preferredSearchText);   //replace the text initially

theSearchBox.blur(function() { //replace the text when the search box loses focus and no value entered
  if ($(this).val().indexOf(defaultSearchText) > -1)
    $(this).val(preferredSearchText);  
  
});

  
});

Revision: 46911
at May 27, 2011 10:37 by rumremix


Updated Code
$(function() {
 
var theSearchBox = $('#searchBoxOuter td.ms-sbcell input');
var defaultSearchText = "Search this site";
var preferredSearchText = "Search my custom site name";
  
theSearchBox.val("Search the Port of Seattle");   //replace the text initially

theSearchBox.blur(function() { //replace the text when the search box loses focus and no value entered
  if ($(this).val().indexOf(defaultSearchText) > -1)
    $(this).val(preferredSearchText);  
  
});

  
});

Revision: 46910
at May 27, 2011 10:32 by rumremix


Updated Code
$(function() {
 var theSearchBox = $('#searchBoxOuter td.ms-sbcell input');
theSearchBox.val("Search the Port of Seattle"); //replace the text initially  
theSearchBox.blur(function() { //replace the text when the search box loses focus and no value entered
if ($(this).val().indexOf("Search this site") > -1)
  $(this).val("Search the Port of Seattle");  
  
});
  
});

Revision: 46909
at May 27, 2011 10:32 by rumremix


Initial Code
$(function() {
 var theSearchBox = $('#searchBoxOuter td.ms-sbcell input');
theSearchBox.val("Search the Port of Seattle"); //replace the text initially  
theSearchBox.blur(function() { //replace the text when the search box uses focus and no value entered
if ($(this).val().indexOf("Search this site") > -1)
  $(this).val("Search the Port of Seattle");  
  
});
  
});

Initial URL

                                

Initial Description
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.

Initial Title
change the default search box text in SharePoint 2010 using JQuery

Initial Tags
javascript, search, jquery, text, sharepoint

Initial Language
JavaScript