I've made divs to display only when their header div is clicked with a toggle on when one is shown the others aren't.
My problem is adding an image that rotates for the correct div that's been clicked at the moment it's only the first image in the first div that rotates, without giving them all their own names & ids, I'm wondering how to differentiate them as I'm a beginner at JS.
Here is my script:
<script>
$(document).ready(function() {
$('a.box').click(function(event){
event.preventDefault();
var sliderContent = $(this).next('.sliderContent');
$('.sliderContent').not(sliderContent).hide();
var element = document.getElementById('spin');
if (element.className === "normal") {
element.className = "rotate";
}
else if ( element.className === "rotate") {
element.className = 'normal';
}
sliderContent.toggle();
});
$('.closeButton').click(function(){
$(this).parent().hide();
});
});
</script>
And the full version: https://jsfiddle.net/ks5nL55k/