0
我得到這個錯誤:Element.classList無法讀取屬性「切換」
Uncaught TypeError: Cannot read property 'toggle' of undefined at HTMLTableCellElement.toto
有人能幫忙嗎?
var comments = document.getElementsByClassName('organisation');
var numComments = comments.length;
function toto(e){
/*this.style.cssText='background-color:white';*/
comments.classList.toggle('.maClasse');
}
for (var i = 0; i < numComments; i += 1) {
comments[i].addEventListener('click', toto, false);
}
對不起!我得到了答案! –
var comments = document.getElementsByClassName('organization'); \t \t var numComments = comments.length; \t \t //功能TOTO(E){ \t \t \t //this.style.cssText='background-color:white'; \t \t \t //comments.classList.toggle('.maClasse') \t \t \t函數myFunction的(){ this.classList.toggle( 「maClasse」); }; \t \t //} \t \t \t 爲\t(VAR I = 0; I
是的是JavaScript,但沒關係,我找到解決方案:)我也編輯也 –