Is there a shorter way ?

3 views
Skip to first unread message

John

unread,
Jul 17, 2009, 1:34:15 AM7/17/09
to DOMAssistant
My approach for attaching a listener is typically to obtain an array
of elements ('a' for example) ...

$$( id ).elmsByTag("a").each(
function(){ $$(this.id).addEvent("click",function(){ **code
to handle click""}); }
);

Since I do so much of this, I thought I'd ask if there is a shorter
way to do this that
doesn't require an id on each element ...

Ex: $$( id ).elmsByTag("a").each( this.addEvent(evt,functionRef)

Thanks,

John Guerin

chenghong

unread,
Jul 17, 2009, 4:12:38 AM7/17/09
to DOMAssistant
Hi John, it can be shortened to:

$("#id a").addEvent("click", function() { **code to handle
click** } );
Reply all
Reply to author
Forward
0 new messages