/ Published in: jQuery
                    
                                        Simply run the function when the document has loaded and specify setDefault to true.
                
                            
                                Expand |
                                Embed | Plain Text
                            
                        
                        Copy this code and paste it in your HTML
 function initInput(setDefault) { var inputValues = {}; if (setDefault == null) setDefault = false; $('input:text, input:password').each(function() { if (setDefault) inputValues['' + $(this).attr('id') + ''] = $(this).val(); $(this).focus(function() { if ($(this).val() == inputValues[$(this).attr('id')]) $(this).val(''); }); $(this).blur(function() { if ($(this).val() == '') $(this).val(inputValues[$(this).attr('id')]); }); }); }
Comments
                    Subscribe to comments
                
                