Using slideToggle() with dynamic content?

Using slideToggle() with dynamic content?

Hello everyone! Im relatively new in the jquery world. I hope you can explain how to get this problem done?

Im loading some dynamic content for a news, and onClick at the a-tag "test" theres a slideToggle for news_text. My Problem is, that im loading some content, and got more newsEntrys...how can i go throug alle the news with the same function?

Thanks in advance!
  1. <!--Hier beginnt ein Newseintrag-->
                    <c:forEach var="n" items="${news}" varStatus="MyStatus">
                    <c:if test="${MyStatus.count<'4'}">
                        <div class="news">
                            <div class="news_headline">
                                <h2>${n.newsDatum}</h2>
                                <a id="test" class="contentlinks">
                                      ${n.newsTitel}
                                </a>
                            </div><!--news_headline-->
                            <p class="news_text">
                                ${n.newsText}
                            </p>
                           
                            <script type=javascript>
                                $(function(){
                                    $('a.contentlinks').click(function() {
                                        $(this).next("div.news_text").slideToggle("fast");
                                    });
                                });   
                            </script>
                        </div><!--class news closed-->
                    </c:if>
                    </c:forEach>
                <!--Hier endet ein Newseintrag-->