JS---예: 버튼을 클릭하여 div 배경색 그라데이션 설정

1525 단어

사례: 단추를 누르면div 배경색 점차적인 변화를 설정합니다


배경색 그래디언트:투명도 설정 <span style="color: #000000;"> my$(</span>"btn").onclick = <span style="color: #0000ff;">function</span><span style="color: #000000;"> () { </span><span style="color: #0000ff;">var</span> opacity = 10<span style="color: #000000;">; </span><span style="color: #0000ff;">var</span> timeId = setInterval(<span style="color: #0000ff;">function</span><span style="color: #000000;"> () { </span><span style="color: #008000;">//</span><span style="color: #008000;"> </span> opacity--<span style="color: #000000;">; </span><span style="color: #0000ff;">if</span> (opacity <= 0<span style="color: #000000;">) { clearInterval(timeId);</span><span style="color: #008000;">//</span><span style="color: #008000;">// </span> <span style="color: #000000;"> } </span><span style="color: #008000;">//</span><span style="color: #008000;"> div </span> my$("dv").style.opacity = opacity / 10<span style="color: #000000;">; }, </span>200<span style="color: #000000;">); }; </span>
 

좋은 웹페이지 즐겨찾기