javascript/jQuery를 사용하여 텍스트 단락을 바꿀 수 있습니까? 약 5 초 지연 타이머가 필요하고 텍스트를 이미지 슬라이드처럼 다른 것으로 바꿔야합니다. 페이드 (fade) 나 효과 (effect)로 굉장 할 것입니다. 나에게 올바른 방향으로 나를 가르치거나 나를 도울 수 있니?시간 초과 된 텍스트 교환?
2
A
답변
1
방법 루프에서는 setTimeout없이 또는 setInterval을
<div id="textMessage"></div>
<div class="textContent" style="display:none">Lorem ipsum dolor sit amet</div>
<div class="textContent" style="display:none">In sit amet diam et arcu aliquam tincidunt. </div>
function slide() {
if (cnt>=texts.length) cnt=0;
$('#textMessage').html(texts[cnt++]);
$('#textMessage')
.fadeIn('slow').animate({opacity: 1.0}, 3000).fadeOut('slow',
function() {
return slide()
}
);
}
$(document).ready(function() {
// save the texts in an array for re-use
$(".textContent").each(function() {
texts[cnt++]=$(this).text();
});
slide()
});
1
setTimeout(function() {
$('#target').html('New Text');
}, 5000); // <- 5 seconds
당신이 먹고 싶어한다면 더
setInterval(function() {
// do some change that will happen every 5 seconds
}, 5000); // <- 5 seconds
0
function changeText(){
document.getElementById('my_div_id').innerHTML = 'text_to_display';
}
당신이 다음 함수 내에서 반복되는 문자열의 배열을 가지고 changetext을 구현할 수
:
function timingex(){
setTimeout("changeText()",5000);
}
+1
은 다음과 같은 평가를 피한다. 'setTimeout (changeText, 5000);' – mplungjan
0
바로 위에 퇴색시키려는 콘텐츠를 넣으십시오 (이름은 #box
).. display:none;
으로 숨 깁니다. 이 그런 예를 들어 사용
function() {
$("#box").delay(5000).fadeIn("slow");
}
1
당신은뿐만 아니라에서는 setTimeout으로 함수를 호출 할 수 있습니다
편집 :
Here is the tweaked demo, without a click and with interval
편집 2 :
jsfiddle이 작동하지 않을 경우를 대비하여 여기에 코드를 붙여 넣으십시오. 여기
<div class="texts">
<p class="text text_1">text 1</p>
<p class="text text_2">text 2</p>
</div>
<script>
setInterval(function(){
var toggle = $(".text").hasClass("toggled");
$(".text_1").animate({opacity: toggle ? 1 : 0});
$(".text_2").animate({opacity: toggle ? 0 : 1});
$(".text").toggleClass("toggled");
}, 1000);
</script>
<style type="text/css">
.texts {
position: relative;
}
.text {
position: absolute;
top: 0;
left: 0;
}
.text_1{
opacity: 1
}
.text_2{
opacity: 0;
}
</style>
관련 문제
- 1. 교환 440 시간 초과 오류
- 2. 1 시간 초과 된 파일에 대한 모니터
- 3. 회원 시간 초과 및 세션 시간 초과
- 4. 시간 초과
- 5. Silverlight에서 인증 된 세션 시간 초과 처리
- 6. 아음속 시간 초과 명령
- 7. PHP와 MySQLi 시간 초과
- 8. asp.net의 시간 초과 작업
- 9. QNetworkAccessManager 시간 초과
- 10. MSMQ -받는 시간 초과
- 11. stream_socket_client 시간 초과
- 12. WCF 시간 초과 문제
- 13. 시간 표현이 24 시간 초과 Excel
- 14. SQL의 시간 초과 절차
- 15. django에서 시간 초과 기능 설정하기
- 16. ASP.Net AJAX 시간 초과 요청이 시간 초과 기간보다 오래 완료되었지만
- 17. nginx php5-fpm 업스트림 시간 초과 (110 : 연결 시간 초과)
- 18. PageMethod 기본 시간 초과
- 19. jQuery에서 시간 초과 설정.
- 20. NSURLConnection 시간 초과?
- 21. SQL 서버 시간 초과
- 22. 플렉스 스트리밍 시간 초과
- 23. IDbTransaction 롤백 시간 초과
- 24. ASP.NET의 세션 시간 초과
- 25. Tomcat 요청 시간 초과
- 26. 자동 세션 시간 초과
- 27. Silverlight - 시간 초과 문제
- 28. ASIHTTPRequest 시간 초과
- 29. jQuery 시간 초과 설정
- 30. 세션 시간 초과 문제
어떤 마크 업 작업중인입니까? 당신은 이미 무엇을 시도 했습니까? 무슨 일이 일어 났습니까, 잘못 되었습니까? 어떤 부분에 붙어 있습니까? –
여기에 뭐든지있다. http://stackoverflow.com/search?q=jquery+animate+delay – mplungjan
[Jquery animation repeating code.] 가능한 중복 (http://stackoverflow.com/questions/5311972/jquery-animation-repeating- 코드) – mplungjan