title: Escape single quotes in jQuery or JavaScript
body: <p>I want to display the following text for the <code>&lt;span&gt;</code> tag. How do I escape the single quotes for the following?</p>
  
  <pre><code>$("#spn_err").text($('#txt1').attr('value')+" is not valid");
  </code></pre>
  
  <p>I want to display the message as '<code>ZZZ' is not valid</code>. Here <code>$('#txt1').attr('value')</code> is a dynamic value. It may have <code>abc</code>, <code>bcc</code>, <code>ddd</code>, <code>zzz</code>. How can I do this?</p>