如何使用JavaScript将创建的红色圆圈更改为绿色圆圈?
#redcircle {
background-image: radial-gradient(
circle,
red,
red 40px,
transparent 20px
);
}
答案 0 :(得分:3)
重置这样的风格:
let circle = document.getElementById('redcircle');
circle.style.backgroundImage = 'radial-gradient(circle, green, green 40px, transparent 20px)';
制作另一种css样式,并替换如下样式:
#greencircle{
background-image:
radial-gradient(
circle,
green, green 40px, transparent 20px
);
let circle = document.getElementById('redcircle');
circle.id = 'greencircle';