javascript - Make input field background image disappear after text is inputted -
i'd make background image input field disappear once user has typed amount of text in it. there simple way in javascript? can bg disappears while field focused, returns once move on next field.
html:
call me @ <input name="phone" type="text" class="phone-field" id="phone">
css:
.form input { background-color:transparent; } .form input:focus { background-color:#edc; background-image:none; } input.phone-field { background-image: (url/images/phonebg.png); background-repeat: no-repeat; background-position: left 1px; }
with jquery, like
$('#phone').focus(function(){ var text = $(this).val(); if(text != ''){ $(this).css('background-image', 'none'); } });
Comments
Post a Comment