I have two divs with a button which when clicked, changes the class (col-lg-6 to col-lg-1) of a div and adds the sectionMinimized class. I'm trying to make it that when the entire div with the sectionMinimized class is clicked, the console logs "hey". For some reason it doesn't work unless I add the:
$('.sectionMinimized').click(function() {
console.log("HEY!");
});
in the console.
Here's the code:
$('.expand-section').click(function() {
buttonId = $(this).attr('id');
console.log(buttonId);
if(buttonId === 'expandEvent') {
$('.event-section').removeClass('col-lg-6');
$('.event-section').addClass('col-lg-3 order-1');
$('.event-section').find('button').addClass('hidden');
$('.permanent-section').removeClass('col-lg-6');
$('.permanent-section').addClass('col-lg-1 order-2');
$('.event-section').addClass('sectionMinimized');
$('.permanent-section').find('h2').addClass('header-minimize');
$('.permanent-section').find('p').addClass('hidden');
$('.permanent-section').find('button').addClass('hidden');
console.log($('.sectionMinimized').attr('id'));
} else {
$('.permanent-section').removeClass('col-lg-6');
$('.permanent-section').addClass('col-lg-3 order-1');
$('.permanent-section').find('button').addClass('hidden');
$('.event-section').removeClass('col-lg-6');
$('.event-section').addClass('col-lg-1 order-2');
$('.event-section').addClass('sectionMinimized');
$('.event-section').find('h2').addClass('header-minimize');
$('.event-section').find('p').addClass('hidden');
$('.event-section').find('button').addClass('hidden');
console.log($('.sectionMinimized').attr('id'));
}
});
$('.sectionMinimized').click(function() {
console.log("HEY!");
});
Can someone advise on how I can get this to run?