How can I check if an element has an event or not with jQuery?
I would like to clone or store that event for later use.
html,
<div class="item">
<a href="#" class="edit">edit</a>
<a href="#" class="delete">delete</a>
<a href="#" class="view">view</a>
</div>
jQuery,
$(".edit").click(function(){
return false;
});
$(".delete").click(function(){
return false;
});
$("a").each( function(i) {
$each = this;
console.log($(this).data('events').click);
if($(this).data('events')){
console.log($each.className);
}
});
error,
TypeError: $(...).data(...) is undefined
Any ideas?
Edit:
I know this similar question and answer, but that is where I get my error message from.