Clearing a default value in a search box with jQuery
- by james6848
Hi,
Can't seem to achieve this simple functionality! All I want is to clear a default search term in an input box when it is clicked. The following works up to a point but clears any other text entered, I would've thought resetting search_form_text should have solved this:
search_form_text = $('#block-search-0 #edit-search-block-form-l').attr('value');
if (search_form_text == 'Enter search keywords here') {
$('#block-search-0 #edit-search-block-form-l').click(function() {
$('#block-search-0 #edit-search-block-form-l').attr('value', '');
search_form_text = '';
});
}
Hmmmm... :)