답변 2개
채택된 답변
+20 포인트
8년 전
setinterval(), clearInterval(), ajax로 응용하여
데이터베이스 상품 테이블의 금액값을 주기적으로
update 하면 될 듯 싶습니다.
아래 소스 응용하셔서 개발해보세요
간단한 예제)
</p><p style="font-size: 14.6667px;"><script type="text/javascript"> </p><p style="font-size: 14.6667px;">
</p><p style="font-size: 14.6667px;">$(document).ready(function(){ </p><p style="font-size: 14.6667px;">
</p><p style="font-size: 14.6667px;">var price = 60000;</p><p style="font-size: 14.6667px;">var count = 0;</p><p style="font-size: 14.6667px;">
</p><p style="font-size: 14.6667px;">$('#price').text(price+"원")</p><p style="font-size: 14.6667px;">
</p><p style="font-size: 14.6667px;">var re = setInterval(function() {</p><p style="font-size: 14.6667px;">
</p><p style="font-size: 14.6667px;"><span style="white-space: pre;"> </span>price -= 1000;</p><p style="font-size: 14.6667px;"><span style="white-space: pre;"> </span>//console.log('re');</p><p style="font-size: 14.6667px;"><span style="white-space: pre;"> </span>count++;</p><p style="font-size: 14.6667px;"><span style="white-space: pre;"> </span>$('#price').text(price+"원");</p><p style="font-size: 14.6667px;"><span style="white-space: pre;"> </span>if(count==60){ </p><p style="font-size: 14.6667px;"><span style="white-space: pre;"> </span>clearInterval(re);</p><p style="font-size: 14.6667px;"><span style="white-space: pre;"> </span>}</p><p style="font-size: 14.6667px;">}, 60000); // 60000 m/s은 1분</p><p style="font-size: 14.6667px;">
</p><p style="font-size: 14.6667px;">}); </p><p style="font-size: 14.6667px;"></script> </p><p style="font-size: 14.6667px;"><p id="price"></p></p><p style="font-size: 14.6667px;">
로그인 후 평가할 수 있습니다
댓글을 작성하려면 로그인이 필요합니다.
답변을 작성하려면 로그인이 필요합니다.
로그인