title: Change width if text in input is not empty
body: <p>I want to make the width of an input field 100% if there is some text present in it.
  I tried the below jquery commands but had no luck.</p>
  
  <pre><code>$("#field").change(function(){
        if($(this).val() != '')
        {
           $(this).css("width",100%);
        }
    });
  
  $('#field').on('change', function() { 
       if($(this).val()!='')
       {
               $(this).css("width",100%);
       }
      });
  </code></pre>
  
  <p>Can anyone tell me what I'm doing wrong or suggest any alternate approaches?</p>