sandoche / Darkmode.js

🌓 Add a dark-mode / night-mode to your website in a few seconds
https://darkmodejs.learn.uno
MIT License
2.71k stars 175 forks source link

createElement at runtime #83

Open messizqin opened 2 years ago

messizqin commented 2 years ago

Hi there, thanks very much for making this awesome project. I have a request if I may. I use javascript to create Dom element at runtime, and tries to apply dark mode on it after created.

let darkmode = new Darkmode(options);
let el = document.createElement('div');
el.style.width = '200px';
el.style.height = '200px';
el.style.background = 'red';
document.body.appendChild(el);
darkmode.toggle();

however, createElement will not be rendered. in my project, I create a lot of element through javascript at runtime, I wonder if there is a way I can get the entire page rendered including elements those created by javascript.