Java Reference
In-Depth Information
You can also remove an individual element with the dispose() method:
a.dispose();
using events
As you know, the $() function returns an extended element object. One of the extension methods is
the addEvent() method, which registers an event listener:
function divClick(e) {
alert("You clicked me!");
}
 
$("myDiv").addEvent("click", divClick);
The addEvent() method accepts two arguments: the event name and the function to execute when
the event fires.
You can also register multiple event listeners with the addEvents() method. Instead of passing a
single event name and function, you pass an object that contains the event names as properties and
the functions as values. For example, the following code registers event handlers for the mouseover
and mouseout events on an element:
function eventHandler(e) {
// do something with the event here
}
 
var handlers = {
mouseover: eventHandler,
mouseout: eventHandler
};
 
$("myDiv").addEvents(handlers);
When an event fires, MooTools passes its own event object (of type DOMEvent ) to the event‐handling
function. This object has a hybrid set of properties and methods: Some are proprietary but most
are standards‐compliant. The following table lists some of the properties available with MooTools'
Event object.
propertY
desCription
The horizontal position of the mouse relative to the browser window
page.x
The vertical position of the mouse relative to the browser window
page.y
The horizontal position of the mouse relative to the client area
client.x
The vertical position of the mouse relative to the client area
client.y
The extended event target
target
The extended element related to the event target
relatedTarget
The type of event that called the event handler
type
 
Search WWH ::




Custom Search