-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
30 lines (24 loc) · 855 Bytes
/
script.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
const domOutput = document.querySelector("#dom-output");
const goLive = document.querySelector("#live");
const html = document.querySelector("#html");
const css = document.querySelector("#css");
const javaScript = document.querySelector("#javascript");
const outputFrame = document.querySelector("#frame");
const inputTextArea = document.querySelectorAll(".input");
goLive.addEventListener('click', (e) => {
if (domOutput.style.display == "none") {
domOutput.style.display = "block";
}
else {
domOutput.style.display = "none";
}
})
inputTextArea.forEach((element, index) => {
element.addEventListener("keyup", () => {
run();
})
})
function run() {
outputFrame.contentDocument.body.innerHTML = html.value + "<style>" + css.value + "</style>";
outputFrame.contentWindow.eval(javaScript.value);
}