Replace special characters in JavaScript
<p>How to replace '$txt$' in javascript.I want to replace all occurrences in the string</p>

<p>It's what i tried</p>

<pre><code>if (html.indexOf('$txt$') &gt; -1) {
    html = html.replace(/$txt$/ig, '&lt;input type=text&gt;&lt;/input&gt;');
}
</code></pre>

<p>but it won't replace the string.What's my mistake.Please help me</p>
