Seeking help to create an FAQ page using HTML, CSS, and jQuery. My goal is to rotate an arrow when a question is opened and revert it back when another question is clicked. I've successfully achieved this with <p>
tags but facing issues with the image rotation. Does anyone have insight on how to accomplish this?
Here's the code I've written: http://jsfiddle.net/jmex1p5g/62/
$(document).ready(function(){
var $li_p = $('ul[class="questions"] li').children('p');
var $li_a = $('ul[class="questions"] li').children('a');
if($li_p.slideToggle().toggleClass('closed')){
$li_p.hide();
}
$('ul[class="questions"] li').click(function() {
var ullist = $(this).children('p:first');
ullist.slideToggle().toggleClass('closed');
var isVisible = ullist.is(".closed");
var siblings = $(this).siblings('li');
$.each(siblings, function (i, key) {
if ($(key).find('a').hasClass('icon_minus')) {
var sibling = $(key).children('p:first');
$(sibling).slideToggle().addClass('closed');
$(key).find('a').removeClass('icon_minus').addClass('icon_plus');
}
});
var img_icon = $(this).children('a');
var image = $(this).children('span');
var realimage = $(image).children('img');
if (isVisible === true){
img_icon.removeClass('icon_minus').addClass('icon_plus');
realimage.removeClass('rotate');
$(this).siblings('img').removeClass('rotate');
} else {
img_icon.removeClass('icon_plus').addClass('icon_minus');
realimage.addClass('rotate');
}
});
});