【发布时间】:2021-05-29 11:38:46
【问题描述】:
当我将 eventListner 放入 input type = "color" 时,颜色没有改变。
let css = document.querySelector("h3");
let color1 = document.querySelector(".color1");
let color2 = document.querySelector(".color2");
let body = document.getElementById("gradient");
color1.addEventListener("input", updateColor);
function updateColor() {
body.style.background = `linear-gradient(to-right, ${color1.value}, ${color2.value})`;
}
color2.addEventListener("input", function () {
body.style.background = `linear-gradient(to-right, ${color1.value}, ${color2.value})`;
});
【问题讨论】:
-
更好地阐述并发布错误。
标签: javascript dom-events