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 the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.