I'm binding a click event to a div element, which is created after clicking on a button. I'm using .live() and this is working. I've heard, that I should not use .live, but .delegate(). So I've tried it, but it is not working, but .live is working.
My working jQuery:
$(".myDiv").live("click",function () {
var Pos = $(this).offset();
$("#Container").css("left", Pos.left).css("top", Pos.top);
});
The not working jQuery:
$(".myDiv").delegate("div","click",function () {
var Pos = $(this).offset();
$("#Container").css("left", Pos.left).css("top", Pos.top);
});
My HTML for the div
<div class="myDiv"></div>
Can anyone tell me, why delegate is not working for me?