/ Published in: jQuery
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
// Put text in the search box and remove it and change the colour when it needs to be used. function search_text() { var search_advice_text = $('#f_search').siblings('label').text(); $('#f_search').val( search_advice_text ).css({'color':'#ccc'}); $('#f_search').focus(function(){ if( $(this).val().length == 0 || $(this).val() == search_advice_text ){ $(this).val( '' ).css({'color':'#444'}); } }).blur(function(){ if( $(this).val().length == 0 ){ $(this).val( search_advice_text ).css({'color':'#ccc'}); } }); }