I have a situation where I am dynamically loading HTML content using AJAX with JQuery. After the content is loaded, I am triggering a click event on specific elements within the newly added HTML.
However, I am encountering an issue when trying to set the CSS properties for these new elements.
Below is the code snippet in question:
function updateScreen(year, month) {
$.ajax({
url:'ajax_php/get_year_data.php',
data: 'year=any',
type: 'post',
success: function(data) {
$('.top-container').html(data);
// Highlight year
$("#" + year).click();
// Trigger click event for month
$("#" + year + ' .' + month).click();
$("#" + year + ' .' + month).css('background-color', convertHex('#9FC7F5', 20));
console.log($("#" + year + ' .' + month).css('background-color'));
}
});
}
The console log displays the expected background color change, however, it does not reflect on the screen itself.
Has anyone encountered this issue before and knows how to resolve it?
Thanks, George