I have the following anchor to which I bind a click event using jQuery:
<a href="javascript:void(0);" class="myanchor">My Anchor</a>
JQuery code:
function my_listener()
{
$('a.myanchor').click(function(e){
e.preventDefault();
my_function();
return false;
});
}
$( document ).ready(function() {
my_listener();
});
Now my goal is to be able to see the bound event to the anchor, i.e my_function()
. I tried using:
console.log($('a.myanchor').attr('onclick'));
But it is returning undefined
. How can know that my_function
is bound to the click event on a.myanchor
? Does it require explicit onclick
attribute definition like:
<a class="myanchor" onclick="myfun();" >
Thanks for your usual help.