update css on AJAX loaded html -
i loading in html ajax using jquery. triggering click event on elements within newly loaded html.
i having problem setting css on newly loaded elements.
here code...
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(); // , month $("#" + year + ' .' + month).click(); $("#" + year + ' .' + month).css('background-color', converthex('#9fc7f5', 20)) console.log($("#" + year + ' .' + month).css('background-color')); } }); }
the console.log returns expect see screen not show change in background color.
can tell me why?
cheers, george
why doing post on get_year_data.php
?
since it's getter request, more restful get.
try this, uses more up-to-date syntax:
function updatescreen(year, month) { $.ajax({ type: 'post', url: '/ajax_php/get_year_data.php', data: {year: 'any'} }).done(function(data) { $('.top-container').html(data); $('#'+year+' .'+month).css('background_color', 'blue'); }); }
and update backend accordingly.
Comments
Post a Comment