const trinagles = $('.dropdownIndicator'); //const containers = $(''); trinagles.each(function () { var target = $(this.dataset.refTarget); target.on('show.bs.collapse', function () { //$(this).parent.addClass('rotate'); $(this).parent().find('.dropdownIndicator').addClass('rotate'); console.log($(this).parent().find('.dropdownIndicator')); console.log('show'); }); target.on('hide.bs.collapse', function () { //$(this).parent.removeClass('rotate'); $(this).parent().find('.dropdownIndicator').removeClass('rotate'); console.log('hide'); }); // bootstrap.Collapse.getOrCreateInstance(document.querySelector(this.dataset.refTarget)) });