I have multiple hrefs that need to link to the proper accordion at the bottom of the page. The code I have now works, however I'm trying to minimize the amount of times I repeat functions as a coworker of mine points out that they are impractical. I have tried the location.hash solution, but it doesnt work for me. Any ideas would be appreciated.
window.contentAssetInitFunctions.push(function() {
$(document).ready(function() {
$("#start").click(function() {
$('#startExchange, #startHeader').addClass('active');
$('#packingSlip, #packingHeader').removeClass('active');
});
$("#pack").click(function() {
$('#packingSlip, #packingHeader').addClass('active');
$('#startExchange, #startHeader').removeClass('active');
});
});
});
<a href="#startHeader" id="start" class="text-link">Learn How</a>
<a href="#packingHeader" id="pack" class="text-link">Learn How</a>
<a class="question" id="startHeader"> EXCHANGE</a>
<div class="answer" id="startExchange">
content
</div>
<a class="question" id="packingHeader">HOW TO START AN EXCHANGE WITH A PACKING SLIP</a>
<div class="answer" id="packingSlip">
content
</div>