I have recently started using JQuery and I am encountering difficulties in binding functions to a dynamically created div.
When the user clicks on a button, new divs are added to a container along with a change in the background color of that container. Users should also have the option to remove the added content by clicking on one of the divs.
I tried implementing this function:
$('.course-delete').click(function() {
var course = $(this).parent();
alert("hello");
$(course).css('background', "#fff");
$(course).empty();
});
However, when I click on the div, nothing seems to happen. Any insights into what might be causing this would be greatly appreciated.