jquery

jQuery Toggle Firing Twice

ben himself's picture

When trying to toggle an element on a page using jQuery, you might have the toggle happen multiple times. In other words, you click the event listening element (such as a link) and the element you want to toggle expands and collapses, then once more expands and collapses. How stupid would that look if you left your site working like that? Pretty stupid.

The reason seems to be that the element was bound more than once so it fires once for each binding. The solution is to unbind the element before calling the toggle.

Tags: 

Pages

Subscribe to RSS - jquery