How to replace ALL * characters in some list?
Example:
<div class="nav">
<ul>
<li><a href="#">Hotels *****</a></li>
<li><a href="#">Hotels ****</a></li>
<li><a href="#">Hotels ***</a></li>
<li><a href="#">Some other menu</a></li>
</ul>
</div>
jQuery example:
$().ready(function () {
if ($('.logo')[0].offsetWidth == 295) {
$('.nav ul li a span').each(function () {
string = $(this).text();
$(this).html('<img src="img/star.png" alt="' + string + '" />');
});
}
});
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.
The goal is to change it like this:
some text *****
with
some text <img src="img/star.png" alt="star" /><img src="img/star.png" alt="' + string + '" /><img src="img/star.png" alt="' + string + '" /><img src="img/star.png" alt="' + string + '" /><img src="img/star.png" alt="' + string + '" />