Answer the question
In order to leave comments, you need to log in
How to access elements generated by javascript?
I need to create a function that is called when a block is clicked, but since this block is generated via javascript the following way is:
$('#delete').click(function(){
alert('works');
})
Answer the question
In order to leave comments, you need to log in
You can delegate an event:
$('body').on( 'click', '#delete', function( event ) {
alert('works');
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question