How do I escape characters in href of anchor tag
<p>I want to escape three characters these are </p>

<ol>
<li>single quote (')</li>
<li>double quote (")</li>
<li>backslash ()</li>
</ol>

<p>my href value is
<code>test.html?key="test' me'"&amp;event=3</code></p>

<p>I want to fix it as we do in <code>php</code> by calling <code>addslashes function</code></p>

<pre><code>&lt;a href="test.html?key="test' me'"&amp;event=3"&gt;test&lt;/a&gt;
</code></pre>

<p><strong>NOTE: I need a dynamic way of doing it</strong></p>