jquery click on dynamically added element code example
Example 1: document on click dynamic element
$(document).on('click', '.class', function() {
});
Example 2: javascript bind event to created element
document.addEventListener('click', function(e){
if(e.target && e.target.id== 'myDynamicallyAddedElementID'){
}
});
$(document).on('click','#myDynamicallyAddedElementID',function(){
});
Example 3: change event doesn't work on dynamically generated elements .
$( "#dataTable tbody" ).on( "click", "tr",
function() {
console.log( $( this ).text() );
});