Run your "is there anything in it" check again "on load". So something like (untested):
$(document).ready(function() { $('#loginArea').addClass('active'); function flagEmpty( elem ) { elem = $(elem || this); // if "elem" isn't passed in then use "this" if (elem.val().length > 0) elem.addClass("nobg"); else elem.removeClass("nobg"); } $('#loginArea.active input') .each( flagEmpty ) .focus( flagEmpty ) .blur( flagEmpty ); $(window).load(function() { $('#loginArea.active input').each( flagEmpty ); }); }); Karl Rudd On Tue, Aug 26, 2008 at 6:26 AM, sperks <[EMAIL PROTECTED]> wrote: > > I have a script that displays username and password as background > images in the input fields when the field is empty and they removes it > when on focus (or when there's content left in the field). I then came > up against the issue where if someone's browser populates the input > fields after their browser is asked to remember their password and I > end up with both the input fields being populated and the background > showing. Here's my initial script: > > $(document).ready(function() { > $('#loginArea').addClass('active'); > $('#loginArea.active input') > .focus(function() { > $(this).addClass("nobg"); > }) > .blur(function() { > if ($(this).val() == '') { > $(this).addClass("nobg"); > }; > }); > }); > > I tried using > $('#loginArea.active input:empty').removeClass("nobg"); > but FF doesn't add the username/password until after the page has > loaded (I don't know what other browsers are doing), and thus the > decision to addClass is based on empty cells. > > Anyone have an idea of how to resolve this one? >