title: How to disable textbox from HTML disabled attribute using jQuery
body: <p>How to write jQuery code for disable textbox of HTML attributes.
  By using jQuery I disabled the textbox based on userId, if <code>userId == ''</code> I want to enable the textbox if <code>userId != ''</code> I want to disabled the textbox.</p>
  
  <pre><code>&lt;input type="text" value="${userJson.firstName}" class="txtcontrolwidth" name="firstName" maxlength="45" id="firstName"
         disabled="if(${userJson.userId} == '') {$('#firstName').attr('disabled', false)} else {$('#firstName').attr('disabled', true)}" /&gt;
  </code></pre>
  
  <p>Every time it is in disabled mode it is not enabled. </p>
  
  <p>By calling outside function for disabling textbox it is easy.</p>
  
  <pre><code>&lt;script type="text/javascript" src="&lt;%=request.getContextPath() %&gt;/js/jquery-1.11.1.js"&gt;&lt;/script&gt;
  &lt;script type="text/javascript"&gt;
  if(${userJson.userId} == "") {
      $('#firstName').attr('disabled', false);
  } else {
      $('#firstName').attr('disabled', true);
  }
  &lt;/script&gt;
  </code></pre>
  
  <p>But I want to disabled textbox in disabled attribute only.</p>