0
Hello, I’m a beginner in jquery and I have the following problem: I have the same element that repeats several times on the page, and when I click on it I need to perform a function. But the function is being executed for all elements that have this class. I would like the function to be executed only for the element I clicked, regardless of having others with the same class. See my jquery here:
const details = $('.open-details');
const additional = $('.additional-texts');
details.each(function(){
$(this).on('click', function(event){
if (additional.hasClass('open')) {
additional.slideUp("slow");
$('.arrow').css('transform', 'rotate(0deg)');
} else {
additional.slideDown("slow");
$('.arrow').css('transform', 'rotate(180deg)');
}
additional.toggleClass('open');
});
});
I would like when you click on the div 'Details' to trigger the rest of the function. I did so but it runs for all Divs 'Details' present on the page. Any help is welcome :)