Pass variable into selector in foreach loop
<p>I have a set of ids being generated in a foreach loop</p>

<pre><code>&lt;?php foreach ($_Collection as $_item): ?&gt;
    &lt;img class="&lt;?php echo $_product-&gt;getId() ?&gt;"  src="&lt;?php echo Mage::helper('catalog/image')-&gt;init($_product, 'small_image')-&gt;resize(100, 75); ?&gt;" /&gt;
</code></pre>

<p>I want to be able to grab specific divs with ajax by using the class that is generated as it will match both in this and the target document.  So I was hoping to try something like this in the same foreach loop :</p>

<pre><code>$(document).ready(function() {  
var item = "&lt;?php echo $_product-&gt;getId() ?&gt;";
$('img .'+item).click(function (){  
$('#result').load('ajax-page .'+item+')
    })
</code></pre>

<p>This is just for an example but I am sure there are multiple things wrong.  For one what is printed looks like ... </p>

<pre><code>var item = "156294";
$j('img .'+item).click(function (){ 
    $j('#result').load('ajax-page .item')
    });
</code></pre>

<p>For starters... how can I pass the <em>item</em> variable to the selector from within this loop?</p>
