change image opacity using javascript

后端 未结 7 1852
失恋的感觉
失恋的感觉 2020-12-05 04:11

how can I change image opacity using javascript? I\'m going to create a fading effect using javascript, is there any sample? is there anything like image.opacity that can be

7条回答
  •  渐次进展
    2020-12-05 04:52

    You could use Jquery indeed or plain good old javascript:

    var opacityPercent=30;
    document.getElementById("id").style.cssText="opacity:0."+opacityPercent+"; filter:progid:DXImageTransform.Microsoft.Alpha(style=0,opacity="+opacityPercent+");";
    

    You put this in a function that you call on a setTimeout until the desired opacity is reached

提交回复
热议问题