Transparent image - is it possible in JS?
Is it possible to set transparency 开发者_StackOverflow社区of any image in javascript? And how can I do that?
If using plain javascript this should work:
function SetOpacity( imageid, opacity ) {
var s= document.getElementById(imageid).style;
s.opacity = ( opacity / 100 );
s.MozOpacity = ( opacity / 100 );
s.KhtmlOpacity = ( opacity / 100 );
s.filter = 'alpha(opacity=' + opacity + ')';
}
Call by: SetOpacity('myImg', 50); //Half transparent
Source here
Yes.
Using jQuery:
$('#yourImageId').css('opacity', .5);
精彩评论