2011-06-07 42 views
0

我有一個事件列表,onClick元素展開,他們應該做相反的第二次點擊。這是我的小腳本不起作用的部分。爲什麼不??Mootools set className

window.addEvent('load',function() { 
    $$('.eventlistitempassive').each(function(item) { 
    item.addEvent('click',function() { 
    $$('.eventlistitemactive').set('class', 'eventlistitempassive block'); 
    item.set('class', 'eventlistitemactive block'); 
    }); 
    }); 
    $$('.eventlistitemactive').each(function(item) { 
    item.addEvent('click',function() { 
     item.set('class', 'eventlistitempassive block'); 
     }); 
    }); 
}); 

見行動腳本在 http://hoch3.cc/index.php/aktuelles.html 感謝, PB

回答

0

這裏的問題是,有上window.load沒有有源元件,所以你的第二個選擇加在每個活動的點擊事件項目沒有找到任何東西。所以,試試這個:奧地利

window.addEvent('load',function() { 
    $$('.eventlistitempassive').each(function(item) { 
    item.addEvent('click',function() { 
     $$('.eventlistitemactive').set('class', 'eventlistitempassive block'); 
     item.set('class', (item.get('class') == 'eventlistitemactive block' ? 'eventlistitempassive block') : 'eventlistitemactive block'); 
    }); 
    }); 
}); 

greatings;)