Hi I am creating a new element and child of that element with beforesend
in Ajax.
Later on I want to show the child element if I click on its parent...
$('#submit-task').on('click', function() {
// variable declarations etc
jQuery.ajax({
// other data
beforeSend: function() {
jQuery('#' + month + ' .month-tasks-design').append(
'<div class="month-task" data-id="' + next_id + '" style="width:0%;background: ' + colour + ';"><div class="task-info">Name: ' + name + '<br />Design Hours: ' + design_hours + '<br />Description: ' + description + '<br /></div></div>');
jQuery('#' + month + ' .month-tasks-dev').append(
'<div class="month-task" data-id="' + next_id + '" style="width:0%;background: ' + colour + ';"><div class="task-info">Name: ' + name + '<br />Development Hours: ' + dev_hours + '<br />Description: ' + description + '<br /></div></div>');
jQuery('.month-tasks-design div[data-id=' + next_id + ']').animate({ width: design_width + '%'}, 1000, function() {});
jQuery('.month-tasks-dev div[data-id=' + next_id + ']').animate({ width: dev_width + '%'}, 1000, function() {});
},
// other data
});
});
$('.month-task').on('click', function(e) {
if ( e.target !== this ) { return; }
var task_info = $(this).find('.task-info');
$(task_info).fadeIn(200);
});
however nothing happens when I click on .month-task
, it does work however with page loaded html, just not with the newly generated html