/ Published in: JavaScript
Expand |
Embed | Plain Text
// // Search form control function // $(document).ready(function(){ // Get default search box value from hidden label $("#keywords").attr("value", $("#search label").text()); // Clear search box only if default value present $("#keywords").focus(function(){ if ($(this).attr("value") == $("#search label").text()) { $(this).attr("value", ""); } }); });
Comments
Subscribe to comments
You need to login to post a comment.

This takes the text content of a hidden label and populates the search input's value with it to save space and work in an accessible way.
When search input is focused on default text is removed.
Requires JQuery