Is there a way where i could bind the events from the newly created elements via jquery.
Heres an example.
HTML:
    <div id="meta_inner" class="gallery">
    <div id="medias">
        <label for="test_meta_boxes1" ><input id="test_meta_boxes1" type="text" size="100" name="ad_image" value="http://" /><input id="test_meta_boxes_button" class="button" type="button" value="Upload Image" data-int="test_meta_boxes1"/></label>
    </div>
    <input class="button tagadd add" type="button" value="Add Image Field">
</div>
jQuery
    jQuery(document).ready(function($){
    var count = $("#medias").children('label').length;
    $(".tagadd").on('click', function() {
        count = count + 1;
        $('#medias').append('<label for="test_meta_boxes'+count+'" ><input id="test_meta_boxes'+count+'" type="text" size="100" name="ad_image" value="http://" /><input id="test_meta_boxes_button" class="button" type="button" value="Upload Image" data-int="test_meta_boxes'+count+'"/></label>' );
        return false;
    });
    $('label').find('#test_meta_boxes_button').on('click', function(e) {
        metabox = $(this).data('int');
        console.log(metabox);
    });
});
When you runs this. The first label will work and print on the console window when the 'Upload Image' button is clicked.
but when i add another label by clicking the 'Add Image Field' button. the 'Upload Image' button will not work.
Am i missing something? any help is appreciated.