Fadein with variable as selector
<p>I'm currently trying to make a hover effect (make a div fadein, and then out when not hovering) on my list of pictures that users has uploadet. Since i dont want all my pictures to hover when one of the pictures are selected, i have made PHP echo out a variable for the divs ids. </p>

<p>In my jQuery code below, i got a loop where i count from 1 to 16 (thats the number of pictures in my gallery) and the selector has the name of the divs.</p>

<p>PHP Part:
    

<pre><code>                        echo "&lt;div class='cell1' id=sovs$sovs style='overflow: hidden; position: relative;'&gt;
                                &lt;a href=image.php?p=$presentnew-&gt;upload_id&gt;
                                &lt;img style='min-width: 177px; min-height: 177px;' src='content/$presentnew-&gt;user_name/thumbs/medium_$presentnew-&gt;file_name'&gt;
                                &lt;div class='celltext'&gt;
                                &lt;b style='color: white; line-height: 28px; margin-left: 5px; font-size: 10pt;'&gt;&lt;a style='color: white;' href='profil.php?bruger=$presentnew-&gt;user_name'&gt;$presentnew-&gt;user_name&lt;/a&gt;&lt;/b&gt;
                                &lt;/div&gt;
                                &lt;/a&gt;
                            &lt;/div&gt;";
                        $sovs++;
                    }
</code></pre>

<p>Javascript Part:</p>

<pre><code>for (var h = 1; h &lt;= 16; h++) {
    $(function() {
        $("#sovs" + h).hover(

        function() {
            alert("g");
        });
    });
}​
</code></pre>

<p>The code above is just a test where i want my divs to respond to the function.</p>

<p>problem is that they dont do that. they will respond if i change the name of the selector to, for instance <code>$('#sovs1')</code>.</p>

<p>Can anybody enlighten me on what I am doing wrong?</p>

<pre><code>$(document).ready(function(){
for(var h=1; h&lt;=16; h++){   
        $("#sovs"+h).mouseover(function(){
                alert("G");                                  
            });   

    }
});
</code></pre>

<p>Works, but if i attach the fadeIn function to it, it doesn't</p>
