I have an event for click-and-hold on a dynamic element
var timeoutId = 0;
$(document).on('mousedown', '.createbtn', function(){
timeoutId = setTimeout(showNewInfoCreateDlg, 1000);
}).on('mouseup mouseleave', '.createbtn', function() {
clearTimeout(timeoutId);
});
and the function is "showNewInfoCreateDlg" I need to know what is the id of the element that was clicked-and-held
function showNewInfoCreateDlg(){
alert($(this).attr('id'));
}
The function alerts "undefined"
Here is the jsfiddle for my problem: