如何使用javascript更改背景图像的透明度?
我有一个元素的重复不透明背景。我需要能够使用javascript更改背景图像的不透明度。我想根据滚动位置调整图像不透明度 我发现这个链接是使用css“after”伪类实现的: 但看起来我无法使用javascript更改伪类的属性。如何使用javascript更改背景图像的透明度?,javascript,css,Javascript,Css,我有一个元素的重复不透明背景。我需要能够使用javascript更改背景图像的不透明度。我想根据滚动位置调整图像不透明度 我发现这个链接是使用css“after”伪类实现的: 但看起来我无法使用javascript更改伪类的属性。 有人知道我是如何做到这一点的吗?试试这样的方法: HTML: JavaScript: document.getElementById("img").style.opacity=0.5; #img{background:url(enter your image fil
有人知道我是如何做到这一点的吗?试试这样的方法:
HTML: JavaScript:
document.getElementById("img").style.opacity=0.5;
#img{background:url(enter your image file url here); width:100%; height:100%;}
document.getElementById("img").style.opacity=0.5;