content.forEach() の処理を記述する場所を教えてください

クリックイベント内に記述しましょう。
2021年9月6日
ユーザー
menuItems.forEach(function(item) {
      item.classList.remove('active');

    item.classList.add('active');
    });
    〇//! contents.forEach(content => {
      content.classList.remove("active"); !//
    })
  })
})
 contents.forEach(content => {
 content.classList.remove("active");

(〇の部分) contentactive クラスを削除しているコードを menuItems.forEach() の括弧外に記載するとブラウザで見た際に最初からコンテンツの内容が記載されないのですが、これはなぜですか?

この回答を見るにはプレミアムプランへの登録が必要です

プレミアムプランとは?