“Mendeteksi JavaScript Mode Gelap” Kode Jawaban

JavaScript mendeteksi mode gelap

const isDarkMode = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches;
Batman

JavaScript mendeteksi mode gelap

const isDarkMode = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches

console.log(isDarkMode) // Result: True or False
Rashid Siddique

Mendeteksi JavaScript Mode Gelap

if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {
    console.log(` is dark`);
}else{
  console.log(`shiit is light`);
}
Marwen Labidi

js jika mode gelap

if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {
    // dark mode
}
Aryqs Ipsum

Deteksi Sistem Mode Gelap Javascrip

 const darkTheme = window.matchMedia("(prefers-color-scheme: dark)");
  if (darkTheme.matches) {
       document.documentElement.classList.add("dark");
    } else {
      document.documentElement.classList.remove("dark");
       }
Dead Dormouse

Jawaban yang mirip dengan “Mendeteksi JavaScript Mode Gelap”

Pertanyaan yang mirip dengan “Mendeteksi JavaScript Mode Gelap”

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya