div의 배경색을 변경하려면 Jquery 애니메이션 기능을 사용하려고합니다. 난수가 50 미만이면 빨간색으로, 50보다 높으면 녹색으로 움직입니다. 색상 변경을 제외한 모든 것이 효과가있는 것 같습니다. 내가 여기서 뭘 잘못하고있는거야?값을 기반으로 배경색으로 페이드 아웃
function randomInt(min,max) {
return Math.floor(Math.random() * (max - min + 1) + min);
}
if (randomInt(1, 100) > 50) {
$('#status').html("win").animate({backgroundColor: "green" }, "fast");
} else {
$('#status').html("lose").animate({ backgroundColor: "red" }, "fast");
}
[이 게시물] (http://stackoverflow.com/q/190560/1806218가) 귀하의 질문에 응답하여
CSS
에transition: background 1s
를 추가하고getElementById
을 사용JavaScript
에 여기. – wannaKnowItAll
중복 됨 http://stackoverflow.com/questions/190560/jquery-animate-backgroundcolor –