How to replace character with image using jQuery?
<p>How to replace ALL * characters in some list? </p>

<p>Example:</p>

<pre><code>&lt;div class="nav"&gt;
        &lt;ul&gt;
            &lt;li&gt;&lt;a href="#"&gt;Hotels *****&lt;/a&gt;&lt;/li&gt;
            &lt;li&gt;&lt;a href="#"&gt;Hotels ****&lt;/a&gt;&lt;/li&gt;
            &lt;li&gt;&lt;a href="#"&gt;Hotels ***&lt;/a&gt;&lt;/li&gt;
            &lt;li&gt;&lt;a href="#"&gt;Some other menu&lt;/a&gt;&lt;/li&gt;
        &lt;/ul&gt;
&lt;/div&gt;
</code></pre>

<p>jQuery example:</p>

<pre><code>$().ready(function () {
    if ($('.logo')[0].offsetWidth == 295) {
        $('.nav ul li a span').each(function () {
            string = $(this).text();
            $(this).html('&lt;img src="img/star.png" alt="' + string + '" /&gt;');
        });
    }
});
</code></pre>

<p>I want to change ALL the stars, not just one (with this code, all works like it should, except it changes all stars with one image). it shuld be how many star char's, that many images.</p>

<p>The goal is to change it like this:</p>

<pre><code>some text ***** 
</code></pre>

<p>with </p>

<pre><code>some text &lt;img src="img/star.png" alt="star" /&gt;&lt;img src="img/star.png" alt="' + string + '" /&gt;&lt;img src="img/star.png" alt="' + string + '" /&gt;&lt;img src="img/star.png" alt="' + string + '" /&gt;&lt;img src="img/star.png" alt="' + string + '" /&gt;
</code></pre>
