简体   繁体   中英

How to get index of clicked element in 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?

Loop through the element collection first.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM