O'Reilly logo

MooTools 1.3 Cookbook by Jay Larry G. Johnston

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Removing a listener that responds to clicks

To release an element from our beck and call when it is no longer needed, we need to have first added an event to it. Since we start this recipe with the Hello World from the previous one, we are ready to remove the event.

Getting ready

We still keep in mind that mybutton will be triggering the action in this recipe.

<input type="button" id="mybutton" value="Greet Me!"/>

How to do it...

First, add a widget called mycancel and provide an onclick attribute that handles the click event. This bound function uses the MooTools Element.removeEvents() without the optional argument of which types of events to remove and therefore removes them all.

<input type="button" id="mycancel" value="Okay, nevermind" onclick=" ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required