このスクリプトリンクの JQ の代替案を見つけて、ID の代わりにクラスを使用したいという問題を確認しようとしています。彼ら。それを機能させる方法はありますか?
function toggle(matchingAttribute) {
// optain all div elements in the page
var divArray = document.getElementsByTagName("div");
for(i=divArray.length-1; i>=0; i--) { // for each div
if(divArray[i].id.match("_"+matchingAttribute+"_")) {
if(divArray[i].style.display != 'none') {
divArray[i].style.display = 'none';
}
else {
divArray[i].style.display = '';
}
}
}
} // end function toggle()