this is a demonstration of the various mjt.for= variants.
(var i = 0; i < 4; i++) i,v in [ 'a', 'b', 'c' ] v in [ 'a', 'b', 'c' ] v in { 'a': 'aa', 'b': 'bb' } k,v in { 'a': 'aa', 'b': 'bb' } c in 'abcd' i,c in 'abcd' elt in document.getElementsByTagName('html')[0].childNodes jquery resultsets should be supported too but no test yet.

variable capture

Unlike Javascript's native for loops, the body of an element with a mjt.for= attribute creates a new variable scope. Variables declared inside the body are not shared across iterations of the loop: this works out very nicely when you want to create an event handler for each item in a list.

When you do want to share a variable, you can declare it outside the mjt.for="". Try View source on this page to see how the buttons below are constructed:

      var shared = 0;
    
          shared++;
        
total: $shared