Set transparency of a DIV and its contents using jQuery

后端 未结 4 1082
心在旅途
心在旅途 2021-02-18 18:15

What is the best way to set the transparency of a HTML DIV element and its contents using jQuery?

4条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-02-18 18:28

    Try this properties

    $('#my_div').css("opacity", "0.5"); //Immediately sets opacity $('#my_div').fadeTo(0, 0.5); //Animates the opacity to 50% over the course of 0 milliseconds. Increase the 0 if you want to animate it. $('#my_div').fadeIn(); //Animates the opacity from 0 to 100%

提交回复
热议问题