How can I insert a variable into a variable string?
<p>I have this code which I need to set a unique <code>title</code>:</p>

<pre><code>var tmpImg = '&lt;img src="/admin/icons/cross.png" title="' + title + '" /&gt;';

$(this).find("tr td input").each(function(){
    title = $(this).attr("value");
    $(this).hide().before(tmpImg);
});
</code></pre>

<p>What I want to happen, is that each time the <code>each</code> iterates over the <code>&lt;input&gt;</code>, it updates the <code>title</code> value in the <code>tmpImg</code> string. I know I could separate the img HTML like below, although I think this would get messy when I need to reuse the image later down the script.</p>

<pre><code>var tmpImg = '&lt;img src="/admin/icons/cross.png" title="';

$(this).find("tr td input").each(function(){
    title = $(this).attr("value");
    $(this).hide().before(tmpImg + title + '" /&gt;');
});
</code></pre>
