Event not firing on Dynamically Created Button.

Event not firing on Dynamically Created Button.

First of all, Thank you for taking some time to help me!

Basically I added an event for buttons with class  DeleteNumber like this:

<script>
$( document ). ready( function() {    $( '.DeleteNumber'). on( 'click', function(){
   console. log( 'Tadaaa!');
});
)};
</script>

and it works fine if I add a regular button like this:

  1. < button class= "DeleteNumber btn btn-success">click me!</button>
Now, I did create a button using the following code:
  1. var newBtn = $( '<button>'). addClass( 'DeleteNumber btn btn-success');
    newBtn. html( 'new button ');
    $( mybuttoncontainer). html( newBtn);
The problem is, when I click the button nothing happens... how could I make my new button respond to the bind event I did create in the first piece of code? thank you for your help!