[jQuey] How select an element by class name, previously loaded in DOM
- by Mattia
I write a simple piece of code that creates a div and assign it a class name:
$('#create_div').click(
function() {
div = $("<div>").addClass("myClass");
$("body").append(div);
}
);
Ok: after "create_div" button is fired the function appends the new div to body container.
Now... : How to select the new element created ? How do I reach it?
I have tried:
$('.myClass').click(
function() {
// do something
}
);
but it doesn't works.
Thanks for the help!