javascript - How do I find click event of anchor tag? -
i want find click event of anchor tag,
i tried following no luck , did common mistake
<script type="text/javascript"> $(function () { $('a').on('click', function () { alert('got you'); }); }); </script> </head> <body> <a href="single-page.html#a1">link text</a> <a href="single-page.html#a2">link text</a> </body>
there's nothing wrong in code.
may using older version of jquery, doesn't have .on()
. added in version 1.7
try:
$('a').click(function () { alert('got you'); });
or:
$('a').bind('click' , function(){ alert('got you'); });
Comments
Post a Comment