title: how to escape single quote in dynamically created HTML tag content
body: <p>In my javascript code,
  I have a variable which have a string. String contains ' or quote in it. Example </p>
  
  <pre><code>var name= "hi's";
  </code></pre>
  
  <p>I am creating a link dynamically in a code. where it is written as a string i.e a variable <code>content</code> will be used dynamically to create a link on html page.  </p>
  
  <pre><code>content= '&lt;a onclick="javascript:fun(\'' + name + '\');"&gt;'
  </code></pre>
  
  <p>Here it is giving problem that quote in variable <code>name</code> completes the string in content. and hence rest portion of content is not recognised..</p>
  
  <p>similar problem arises if <code>var name = 'hi"s';</code>
  i.e. if double quote is present in it. </p>
  
  <p>plz help</p>