I\'d like to make the background image for my input field disappear once the user has typed any amount of text in it. Is there a simple way to do that in javascript? I can get i
Or for maximum browser compatibility (ahem, IE):
$("input.phone-field").change(function() { $.trim($(this).val()) != "" ? $(this).toggleClass("bg", false) : $(this).toggleClass("bg"); });
And the markup:
Just add the background image CSS code to the ".phone-field.bg" selector.
This would remove the background as soon as some text is entered (and bring it back if no text is entered).