July 2011
Intermediate to advanced
276 pages
5h 11m
English
Here again, we extend our base object imgmootater.
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'));
});
}
});
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 ...