We Recommend

Pro JavaScript Techniques Pro JavaScript Techniques
Pro JavaScript Techniques is the ultimate JavaScript book for the modern web developer. It provides everything you need to know about modern JavaScript, and shows what JavaScript can do for your web sites. This book doesn't waste any time looking at things you already know, like basic syntax and structures.


Posted By

ianmonge on 09/13/08


Tagged

javascript array function shortcut mootools each


Versions (?)


Who likes this?

2 people have marked this snippet as a favorite

SpinZ
stephenns


Element Collection Manipulation Shortcut Using MooTools 1.2


Published in: JavaScript 


URL: http://davidwalsh.name/element-collection-manipulation-shortcut-using-mootools

  1. // MooTools Looping Example (Bad/Long)
  2.  
  3. $$('.toggler').each(function(el) {
  4. el.addEvent('mouseenter',function(e) {
  5. el.fireEvent('click');
  6. });
  7. });
  8.  
  9.  
  10.  
  11. // MooTools Collection Example (Good/Short)
  12.  
  13. $$('.toggler').addEvent('mouseenter', function() { this.fireEvent('click'); });

Report this snippet 

You need to login to post a comment.