im having trouble about the `on('click')` event, i have a `button` that comes from `ajax` that has a `click event` but when i tried clicking it nothing happens the expected output is showing an `alert` after clicking the button. I tried to test putting the button directly to the html and it worked. Can someone help me about this?

PS: There are no errors in the `console` and `network`

initializing.

```
$( document ).ready(function() {
    init();
});

function init()
{
    sendmessage();
    viewhotel();
    getresorts();
}

```

Function when button is click 

```
function viewhotel()
{
    $('#viewinfo').on('click', function() {
        alert('asd');
    });
} 

```

ajax code where button came

```
$output  .= '<div class="hotel-container">
                                    <div class="row">
                                        <div class="col-md-4">  
                                            <img src="admin/'.$row['main_picture'].'"class="img-responsive hotelpic">
                                        </div>

                                        <div class="col-md-5">
                                            <h5 class="hotelname">'.$row['resort_name'].'</h5>
                                            <h5 class="address"><i class="fa fa-map-marker" aria-hidden="true"></i>&nbsp;&nbsp;&nbsp;'.$row['resort_address'].'</h5>
                                        </div>

                                        <div class="col-md-3">
                                            <h5 class="price">&#8369; '.$row['resort_total_cost'].'</h5>
                     /*here's the button*/  <button class="btn btn-warning" id="viewinfo">View more info</button>
                                        </div>
                                    </div>

                                </div>';

```