Make input field background image disappear after text is inputted

前端 未结 4 580
北荒
北荒 2021-01-24 07:59

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

4条回答
  •  日久生厌
    2021-01-24 08:01

    with jquery, you could do something like

     $('#phone').focus(function(){
         var text = $(this).val();   
         if(text != ''){
            $(this).css('background-image', 'none');       
         }
     });
    

提交回复
热议问题