PHP While Loop and jQuery
<p>I have created a while loop that selects random images from from my server and posts it. Now I want to add some jquery code and allow me to click on one of the images and run the slideUp() function in jQuery. Here is my problem. I can click on the first image produced in the while loop but when I click on the second image nothing happens. The slideUp() function does not work. I don't know what to do. Here is the code below.</p>

<pre><code>&lt;script src="http://code.jquery.com/jquery-latest.js"&gt;&lt;/script&gt;

&lt;?php    
   $num_dresses = dress_count ();   
   $i=0;    
   while ($i &lt; 2){  
?&gt;

&lt;style&gt;     
   div:hover { border:2px solid #021a40; cursor:pointer;}      
&lt;/style&gt;

&lt;script&gt;  
    $("div").click(function () {
           $(this).slideUp();    
    });
&lt;/script&gt;   

&lt;?php       
    $rand_id = rand(1, $num_dresses);       
    $dress_feed_data = clothing_data($rand_id, 'file_name', 'user_defined_name', 'user_defined_place' , 'user_who_uploaded', 'match_1');
    $new_file_name = $dress_feed_data['file_name']; 

    if (file_exists('fashion_images/' . $new_file_name)){

      echo str_replace("|", " ", $dress_feed_data['user_defined_name']);
?&gt;

    &lt;br&gt;                    
    &lt;div&gt;    
     &lt;img  src=" fashion_images/&lt;?php echo $new_file_name;?&gt; " width="50" height="50" /&gt;  
    &lt;div&gt;
        &lt;br&gt;&lt;br&gt;  
    &lt;?php      
        echo str_replace("|", " ", $dress_feed_data['user_defined_place']);      
    ?&gt;

    &lt;br&gt;&lt;br&gt;

    &lt;?php
    }    
    $i++;           
    }    
?&gt;
</code></pre>
