如何在Mootools中获取点击元素的索引

问题描述:

如何像在jQuery中那样在Mootools中获取元素的索引. 例如:

how to get index of element in Mootools like in jQuery. For example:

    this.controls.addEvent('click', function(event){
        if (this.hasClass('h-inactiveslideshowcontrol')) {
            alert(this.index);
        }
    });

如何获取点击元素的索引?

How to get index of clicked element?

首先遍历元素集合.

this.controls.each(function(element, index){
    element.addEvent('click', function(event){
        if (this.hasClass('h-inactiveslideshowcontrol')) {
            alert(index);
        }
    });
});