For dynamically added elements you need event delegation, use the other version on jQuery on(), you can delegate event to static parent of the dynamically added elements. In your case you can use #main_body
$('#main_body').on( "click", "#but", function() { alert( "bla bla" ); });