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)?
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)?
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.
$('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.