I am binding the click event to 4 href's (they have class="alink") using JQuery in the ready() event like this: $(".alink").click(function() { debugger; });
I expect whenever I click on a link, the event fires. However what I notice is that sometimes it doesn't fire and when it fires, it fires 4 times. Am I not doing it right?
EDIT:
<div id="nav">
<ul>
<li class="current"><a href="default.aspx" title="Home" class="alink">home</a></li>
<li><a href="faq.aspx" class="alink">faq</a></li>
<li><a href="" title="Webmail" class="alink">webmail</a></li>
<li><a href="contactus.aspx" title="contact" class="alink">contact us</a></li>
</ul>
</div>
Actually I found the problem. The event handler was inside another function!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.