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

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -