开发者

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);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜