What is difference between these two codes ?
$(document).on(\'click\', \'.close_modal_window\', function(){ alert(\"window closed\"); });
first it works if you have static html which you write like My div second it works if you make/create dynamic html like var myDiv ='My div' and then you append it in some element like $('#someid').append(myDiv ) the second approach is called event delegation
first it works if you have static html which you write like
first
My div
second it works if you make/create dynamic html like var myDiv ='My div' and then you append it in some element like
second
var myDiv ='My div'
$('#someid').append(myDiv ) the second approach is called event delegation
$('#someid').append(myDiv )