Return to Snippet

Revision: 44837
at April 19, 2011 21:21 by jurajhilje


Initial Code
// 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" />

Initial URL

                                

Initial Description

                                

Initial Title
Wordpress and Joomla - like search input (remove default value on focus)

Initial Tags
search, jquery

Initial Language
jQuery