/ Published in: JavaScript
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!
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
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); } }); });