$(function() {
$('body').on('click', '.ap_accordion', function(event) {
var $head = $(event.target);
var $this;
var $next;
if ($head.hasClass('ap_accordion-head')) {
var $this = $(this);
var $next = $head.next();
$next.slideToggle('fast');
// // Clean up other panels:
$this.children('.ap_accordion-panel').not($next).slideUp('fast');
$this.children('.ap_accordion-head').not($head).removeClass('ap_accordion-head-active');
if ($head.hasClass('ap_accordion-head-active')) {
$head.removeClass('ap_accordion-head-active');
} else {
$head.addClass('ap_accordion-head-active');
}
}
});
});
HTML:
<div class="ap_accordion">
<h3 class="ap_accordion-head ap_accordion-head-active">Consider nicotine gum, patches, or pills</h3>
<div class="ap_accordion-panel">
<h4 class="ap_accordion-subhead">This can help fight cravings and <u>double</u> your chance of success!</h4>
<div class="ap_accordion-body">
<p>Cras malesuada ultrices augue molestie risus.</p>
</div>
</div>
<h3 class="ap_accordion-head">Tell my friends or family</h3>
<div class="ap_accordion-panel">
<h4 class="ap_accordion-subhead">It’s easier to quit with support from people who are important to you</h4>
<div class="ap_accordion-body">
<p>Lorem ipsum dolor sit amet mauris eu turpis.</p>
</div>
</div>
<h3 class="ap_accordion-head">Use something else</h3>
<div class="ap_accordion-panel">
<h4 class="ap_accordion-subhead">Like <a href="https://smokingcessationleadership.ucsf.edu/for-smokers/quitline" target="_blank">Quitline</a>, <a href="https://smokefree.gov/" target="_blank">smokefree.gov</a>, or something else</h4>
<div class="ap_accordion-body">
<p>Vivamus facilisisnibh scelerisque laoreet.</p>
</div>
</div>
</div>
Nothing to write home to mom about:
JS:
HTML: