I have written a Javascript for-loop to auto-hide and show-on-click some content on my website, but for some reason, the variable is taking the highest value at the end of the loop...
So
for (var i = 1; i <= 5; i++) {
$('.views-row-' + i + ' .faq_answer').hide();
$('.views-row-' + i + ' .faq_more').click(function () {
$('.views-row-' + i + ' .faq_answer').slideToggle();
});
}
All .views-row .faq_answer elements hide as they should and all .views-row .faq_more have a clickhandler.
But for some reason the slideToggle line only applies on the line with class views-row-6 (which isn't there)...
So the i-variable in the function doesn't apply on all values of the loop...
How can I make it apply on all view-row-x's?