change image opacity using javascript

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

    In fact, you need to use CSS.

    document.getElementById("myDivId").setAttribute("style","opacity:0.5; -moz-opacity:0.5; filter:alpha(opacity=50)");
    

    It works on FireFox, Chrome and IE.

提交回复
热议问题