How can I translate the following jquery idiom to YUI?
$("a").click(function(event){
alert("Saw a click!");
});
The above is supposed to add a custom on-click event to all anchor tags in the document.
Better to use event delegation
YUI 3*
Y.delegate('click', function (e) {
alert("Click received");
}, document, 'a');
or
Y.get(document).delegate('click',fn, 'a');
YUI 2
YAHOO.util.Event.on(document,'click',function (e) {
var target = YAHOO.util.Event.getTarget(e);
if (target.nodeName && target.nodeName.toLowerCase() === 'a') {
alert("Click received");
}
});