how to hide the div when its comes from while loop
<p>the div will created from while loop.i want to click the class accordion1.i want to hide the accordion1body div.</p>

<pre><code>&lt;?php while($timeline1=mysqli_fetch_assoc($timeline))
                { ?&gt;
    &lt;div class="accordion-section"&gt;
                    &lt;div id="accordion1"&gt;
                    &lt;img src="images/user.jpg"&gt;
                    &lt;div class="triangleshape"&gt;&lt;/div&gt;
                    &lt;div class="tit"&gt;3rd Feb 2016 - Hospital Visit&lt;/div&gt;
                    &lt;div class="righticon"&gt;&lt;i class="fa fa-angle-down"&gt;&lt;/i&gt;&lt;/div&gt;

                    &lt;/div&gt;
                    &lt;div id="accordion1body"&gt;
                        &lt;p&gt;The best-known type of hospital is the general hospital, which has an emergency department..&lt;/p&gt;
                    &lt;/div&gt;
                &lt;/div&gt; 
    &lt;?php } ?&gt;
</code></pre>

<p>This script i am used for the hide option.it will works only first loop.</p>

<pre><code> &lt;script&gt;
     $(document).ready(function()
     {
     $("#accordion1").click(function()
     {
     $("#accordion1body").slideToggle();
     });
     });
    &lt;/script&gt;
</code></pre>

<p>if generate separate id for the div.how can I use script click function</p>