목차
- :animated 예제 - 현재 움직이는 요소 배경색 변경.
- :animated 정의
- :animated 구문
:animated 예제 - 현재 움직이는 요소 배경색 변경.
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
function move(){
$("div:eq(0)").animate({width: "50%"}, "slow");
$("div:eq(0)").animate({width: "100%"}, "slow", move);
}
move();
$(".btn").click(function(){
$(":animated").css("background-color", "red");
});
});
</script>
<button class="btn">클릭</button>
<div style="background:lightblue;">홈짱닷컴</div>
<div style="background:pink;">Homzzang.com</div>
<div style="background:yellow;">홈페이지 제작관리 강의</div>
결과보기
:animated 정의
현재 움직이는 동적 요소 모두 선택.
:animated 구문
$(":animated")