私がこれを行う必要があるのは、.info がクリックされたときに .information を切り替えることです。同時に、これにより、他のすべての .information div が非表示になります。私は現在これを行うことができます。私の問題は、開いている .information div をクリックして閉じたときに閉じないことです。これを行うには、次のコードをどのように修正できますか? 私は toggle() を持っているので、うまくいくと思いましたか? jQueryを把握するだけ!!
<ol id="resonsToCome">
<li>
<p>A packed and extensive activites programe</p>
<div class="info">
<img src="images/icons/information.png" width="24" height="24" />
</div>
<div class="information">
<p>The 40+ activities range from 1 to 2 hours. As everything is on site there is no time wasted travelling which ensures up to 5/6 activities per day.</p>
</div>
</li>
<li>
<p>Instructors stay with their group throughout your stay</p>
<div class="info">
<img src="images/icons/information.png" width="24" height="24" />
</div>
<div class="information">
<p>Building a trust and friendship with our customers makes your stay memorable in so many ways.</p>
</div>
</li>
<li>
<p>Friendly and experienced instructors</p>
<div class="info">
<img src="images/icons/information.png" width="24" height="24" />
</div>
<div class="information">
<p>Our instructors take part in a rigorous selection and continuous training programme.</p>
</div>
</li>
<li>
<p>A great environment and perfect location!</p>
<div class="info">
<img src="images/icons/information.png" width="24" height="24" />
</div>
<div class="information">
<p>25 acres of beautiful Somerset fields, woodlands and river only 2 hours from London and 1 hour south of Bristol and Bath.</p>
</div>
</li>
</ol>
そして、jQuery
$('div.info').on('click', function() {
$('.information').hide();
$(this).closest('ol#resonsToCome li').find('.information').toggle();
});