I'm creating a div with a span on the spot using jquery, like so

```
$("[data-modal]").click(function(event) {
    event.preventDefault();

    var container = $("<div></div>").addClass("modal m-form").appendTo(document.body);
    var close = $("<span></span>").addClass("modal-close").appendTo(container);
}

```

so far so good...

Then, i'm binding an event to the selector **modal-close**, like so

```
$(".modal-close").click(function(event) {
    alert("close the dialog");
});

```

That one doesn't work, so i've tried this one, with no success:

```
$(".modal-close").on("click", function(event) {         
    alert('close the dialog');
});

```

What am i doing wrong?