What is difference between these two codes ?
$(document).on(\'click\', \'.close_modal_window\', function(){
alert(\"window closed\");
});
The difference between the two is that the second version of your code only binds the click function to elements with a class of close_modal_window that are on the page when it loads. The first version of your code binds the click action to any element on the page that ever appears with the close_modal_window class, even if it appears dynamically after the page loads.