Answered by:
how to get searchbox id from jquery in sharepoint 2010 to add watermark

Question
-
how to get searchbox id from jquery in sharepoint 2010.
Id it generates it something like ctl....searchbox.
How can I get searchbox id in jquery for watermark
sharepointerWednesday, December 22, 2010 10:21 AM
Answers
-
You could use JQuery Selectors to get the search box element [explained in following URL]
http://api.jquery.com/category/selectors/
You could leverage "Attribute Ends With Selector" using jQuery('[id$="searchbox"]')
In case of our since the master page was customized we used following [Attribute Starts With Selector]
Hope this helps<script type="text/javascript"> function searchConfiguration() { $("input[id^='<%= SearchBoxExMain.ClientID %>']").watermark('Type your Keyword here...', { className: 'searchBox-watermark' }); $("input[id^='<%= SearchBoxExMain.ClientID %>']").attr("title", "Type your Keyword here..."); $("input[id^='<%= SearchBoxExMain.ClientID %>']").css("color", "#000000"); } _spBodyOnLoadFunctionNames.push("searchConfiguration"); </script>
- Proposed as answer by CoreyRoth [MVP]MVP Wednesday, December 22, 2010 3:37 PM
- Marked as answer by Stanfford Liu Thursday, December 23, 2010 9:43 AM
Wednesday, December 22, 2010 3:18 PM
All replies
-
You could use JQuery Selectors to get the search box element [explained in following URL]
http://api.jquery.com/category/selectors/
You could leverage "Attribute Ends With Selector" using jQuery('[id$="searchbox"]')
In case of our since the master page was customized we used following [Attribute Starts With Selector]
Hope this helps<script type="text/javascript"> function searchConfiguration() { $("input[id^='<%= SearchBoxExMain.ClientID %>']").watermark('Type your Keyword here...', { className: 'searchBox-watermark' }); $("input[id^='<%= SearchBoxExMain.ClientID %>']").attr("title", "Type your Keyword here..."); $("input[id^='<%= SearchBoxExMain.ClientID %>']").css("color", "#000000"); } _spBodyOnLoadFunctionNames.push("searchConfiguration"); </script>
- Proposed as answer by CoreyRoth [MVP]MVP Wednesday, December 22, 2010 3:37 PM
- Marked as answer by Stanfford Liu Thursday, December 23, 2010 9:43 AM
Wednesday, December 22, 2010 3:18 PM -
We just used QueryPromptString property of searchboxex control and its working fine for us.
MCTS Sharepoint 2010, MCAD dotnet, MCPDEA, SharePoint Lead
Thursday, September 13, 2012 7:44 PM -
Ajay,
Have you tried in sharepoint 2013. If so can you please share me the code .
Thanks,
Sandy
Monday, December 22, 2014 4:19 AM