经过一些游戏,发现了
getComputedStyle,我已经把这个在一起了。
#element {
背景色: RGB (10,10,10 );
背景色: rgba (10、10、10、1 );
}
hml element.prototype.alpha=function {
current _ color=getcomputedstyle (this ).getpropertyvalue ) (background-color );
match=/rgba? ((d ) s*,s* ) (d ) (s*,s* ) (d ) ) s* ),s*d [.d ]* ) ) ) g.exec )抄送
a=a 1? (a/100 ) : a;
this.style.background color=' rgba ' [ match [1],match[2],match[3],a].join ';
}
this is some内容。
e=document.getelementbyid (element );
e .阿尔法(20;
由于RGBA为css3,因此请定义CSS的值并确保级联。 另外,1是alpha,可以传递将其除以100的值(使用小数时不喜欢考虑百分比)。 玩得开心!