liner-gradient 를 자바스크립트에서 사용하는 법 질문드립니다.
조회수 679회
const colors = ["red", "yellow", "blue", "black", "purple"];
const btn = document.querySelector('button');
function colorChange() {
let c1 = colors[Math.floor(Math.random() * colors.length)];
let c2 = colors[Math.floor(Math.random() * colors.length)];
const bg = document.querySelector('body');
bg.style.background = `liner-gradient(to right, ${c1}, ${c2})`;
}
btn.addEventListener('click', colorChange);
리니어 그라디언트를 자바 스크립트에서 적용시키어
웹페이지의 배경을 랜덤하게 변경 시키고 싶은데요,
어디가 잘못되었는지 색상이 섞이지 않습니다. 어디가 틀렸는지 알려주세요
댓글 입력