我只想切换在单击操作上滑动的 div 中的“.plus”和“.minus”元素。
HTML
<div class="notification-box-heading">
This is an Alert!
<span class="plus"><img src="http://www.cti-w.com/images/info.png"></span>
<span class="minus"><img src="http://www.cti-w.com/images/close.png"></span>
</div>
<div class="notification-box-body">
<strong>This is an alert!</strong>
<p>This is the alert subtext.</p>
</div>
<div class="notification-box-heading">
This is another Alert!
<span class="plus"><img src="http://www.cti-w.com/images/info.png"></span>
<span class="minus"><img src="http://www.cti-w.com/images/close.png"></span>
</div>
<div class="notification-box-body">
<strong>This is an alert!</strong>
<p>This is the alert subtext.</p>
</div>
JS
$(document).ready(function () {
//hide the all of the element with class notification-box-body
$(".notification-box-body").hide();
//hide the all of the element with class minus
$(".minus").hide();
//slides the element with class "notification-box-body" when paragraph with class "notification-box-heading" is clicked
$(".notification-box-heading").click(function () {
$(this).next("div.notification-box-body").slideToggle(300);
$(".minus").toggle();
$(".plus").toggle();
});
});
有任何想法吗?