Regards. I am generating an .click event for every element of my table using a php loop like this:
<?php foreach ($elements as $element){ ?>
var element_id = <?= json_encode($element['element_id']));?>;
$('#'+element_id+'_button').click(function() {
$('#'+element_id+'_interval').toggle();
if ($(this).hasClass('active')){
$(this).removeClass('active');
}
else{
$(this).addClass('active');
}
});
<?php }?>
the problem is, when $('#'+element_id+'_interval').toggle(); the element is not responding but it adds and removes the classes correctly, somebody help me please.