/ Published in: jQuery
                    
                                        
                            
                                Expand |
                                Embed | Plain Text
                            
                        
                        Copy this code and paste it in your HTML
// Javascript
var $searchInput = $('#search-input'),
defaultSearchInputValue = $searchInput.attr('value');
$searchInput
.focus(function()
{
if($(this).attr('value') == defaultSearchInputValue) $(this).attr('value', '');
})
.blur(function()
{
if($(this).attr('value') == '') $(this).attr('value', defaultSearchInputValue);
});
// HTML
<input type="text" id="search-input" value="Search" />
Comments
 Subscribe to comments
                    Subscribe to comments
                
                