我目前遇到麻煩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>
非常感謝你,我不知道我能參考下一個元素就是這樣。 :) –