Set transparency of a DIV and its contents using jQuery

后端 未结 4 1083
心在旅途
心在旅途 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:31

    As theIV said you can use the css method, but as an alternative you can use animate:

    $('#my_element').animate({ opacity: 0.5 }, 100);
    

    this will animate the opacity of you div (and its contents) to 0.5 (from whatever it was to begin with) in 100 milliseconds.

提交回复
热议问题