Extending images—lazy load

Here again, we extend our base object imgmootater.

Getting ready

And, again, the preparation for this recipe is the imgmootater class itself. Sound the trumpets!

var imgmootater = new Class({
initialize: function() { this.imgs = $$('img'); },
make_titles: function() {
this.imgs.each(function(el){
el.set('title',el.get('alt'));
});
}
});

How to do it...

Extend the imgmootater class. Perhaps somewhat academically, we are extending something that already does an action we need. In this case, at least academically, we are demonstrating a recipe that shows that imgmootater does a great deal of important, reusable work. In this example, what it does is duplicate the ALT attribute metadata into the TITLE attribute so that mouse ...

Get MooTools 1.3 Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.