1

我目前遇到问题 jquery 我正在尝试触发一个事件,当用户单击文章的标题时,隐藏的段落片段显示在它下面淡入,我的问题是每次单击一个标题时段落显示在所有其他标题下我如何才能触发我单击的标题的段落?这是 HTML 代码:

    <div id="content">
    <div class="column">
    <div class="Article">
    <img src="images/SteveJobs.png" alt="Steve Jobs" Title="SteveJobs" />
    <h1><a href="#"> Computers changed Forever</a></h1>
    <p> The Brilliant Mind of Steve Jobs. </p>
    </div>
    <div class="Article">
    <img src="images/Cannibal.png" alt="Cannibal" Title="Randy Cannibal" />
    <h1><a href="#"> Face-Eating Cannibal Attack May Be Latest in String of 'Bath Salts'        Incidents</a></h1>
    <p> On May 26, Miami police shot and killed a homeless man who was allegedly feasting on the face of another homeless man in a daylight attack on a busy highway.  </p>
    </div>
    </div>
    </div>

这是Javascript

    <script type="text/javascript">
       $(document).ready(function() { 
      $('.Article h1 a').click(function() {
     $('.Article p').each(function() {
         $(this).fadeIn(3000).show();
            });
           });
         });
     </script>
4

2 回答 2

2
$('.Article h1 a').click(function(event) {
     event.preventDefault();
     $(this.parentNode).next('p').fadeToggle(3000);
     // $(this).closest('.Article').find('p').fadeIn(3000);
});
于 2013-05-18T00:26:18.517 回答
1

这将解决您的问题

<script type="text/javascript">
           $(document).ready(function() { 
                $('.Article h1 a').click(function() {
                   $(this).parent().next().fadeIn(3000);
               });
          });
         </script>
于 2013-05-18T00:28:04.967 回答