Return to Snippet

Revision: 38384
at December 31, 2010 12:03 by browncardigan


Initial Code
var clearedFields = new Array();

$(document).ready(function() {
	$(':text').click(function() {
		var field_name = $(this).attr('name');
		if (jQuery.inArray(field_name, clearedFields) < 0) {
			$(this).attr('value', '');
			clearedFields.push(field_name);
		}
	});
});

Initial URL

                                

Initial Description
simply script to clear a text field (ie. a search field) ... but only does it once, just in case the user returns the field to type more...... USABILITY!

Initial Title
jquery : clear input text fields on click - BUT only once!

Initial Tags

                                

Initial Language
JavaScript