javascript - jQuery - on load of element with ajax -
javascript - jQuery - on load of element with ajax -
i searched time not find working solution problem (sorry if searched wrongly)... have equivalent of next function element loaded ajax:
$(document).ready(function() { $('.div-modal-text').css("background-color","red"); });
therefore using next code:
$('#parent_id').on('action', '#id or class born', function performed() );
in illustration parent-child construction is: #projectmodals (div content dynamically loaded)>...>.div-project-description>.div-modal-text
this translates next code in example:
$('#projectmodals').on('load', '.div-project-description', function() { $(this).find('.div-modal-text').each(function() { $(this).css("background-color","red"); }); });
i know 'load' not work .on(), tried different alternatives , not find working.
thanks help!
edit: here (simplified) html code:
<div id="projectmodals"></div>
content loaded in #projectmodals ajax:
<div class="row"> <div class="div-project-idcard"> column 1, don't bother much column </div> <div class="div-project-description"> <div id="summary" class="div-modal-text"> column2, text 1 </div> <div id="purpose" class="div-modal-text""> column2, text 2 </div> <div id="reforestation" class="div-modal-text"> column2, text 3 </div> <div id="certification" class="div-modal-text"> column2, text 4 </div> </div> </div>
if you're waiting loaded via ajax, consider using $(window).ajaxsuccess()
instead:
$(window).ajaxsuccess(function(){ $('#projectmodals .div-project-description .div-modal-text').each(function() { $(this).css("background-color","red"); }); });
javascript jquery ajax
Comments
Post a Comment