tags:

views:

32

answers:

2

Let's save I have an Element:

var el = $('mooo');

What's the easiest way to set its 'onclick' attribute or event (it may already have one)?

+4  A: 

MooTools handles all its event adding with the addEvent() function:

var el = $('mooo');
el.addEvent('click',function(){ alert("I got clicked!"); });

Event names simply have the "on" prefix removed, ie. 'click','mouseover','mouseenter', etc.

zombat
A: 

$('mooo').addEvent('click', function(e){ // your code here. e.stop(); });

You mention, regarding events, that your element mooo may already have one. This should not affect this code.

artlung