change image opacity using javascript

后端 未结 7 1858
失恋的感觉
失恋的感觉 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:48

    First set the opacity explicitly in your HTML thus:

    otherwise it is 0 or null

    this is then in my .js file

    document.getElementById("fadeButton90").addEventListener("click", function(){
    document.getElementById("box").style.opacity  =   document.getElementById("box").style.opacity*0.90; });
    

提交回复
热议问题