HTML: As I understand it, you're starting with something like this...
<div id="files_wrapper">Stuff in here</div>
And, you might then add some button that creates a new button within your application:
<div class="action add" data-type="file-delete">Add Option (Delete)</div>
JavaScript: You need to add some script to add a button, which itself as a listener.
// Find your application section
var app = $('#files_wrapper');
// Make an element to clone
var deleteFile = $('<div>').addClass('action delete').html('Delete file');
// Find your trigger that adds the button
$('.action.add[data-type="file-delete"]').on('click.fileaction', function () {
// Clone your template button
var deleteButton = deleteFile.clone();
// Add your listener that reponds to the delete button being pressed
deleteButton.on('click.delete-file', function () {
$(this).toggleClass('clicked')
})
// Add it to the application
app.append(deleteButton)
})
This is the kind of thing that you want to do to build a DRY application using jQuery.
jsFiddle example: https://jsfiddle.net/likestothink/shra07Lp/1/