/ 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.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
$(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); }); });