I have a little problem with jQuery.
I try to show multiple texts in a div. these divs shoud fadein and fadeout and in the end the function should restart.
i wrote a simple example and when it runs. it starts fine…
- one
- two
- three
- four
- five
- six
when the function is looped the problem beginns. it shows the following order:
- two
- four
- five
- six
and starts then over with this order.
i don’t get it. Can anybody point me in the right direction?
thats the script:
<html>
<head>
<script type="text/javascript" src="jquery151.js"></script>
<script type="text/javascript">
$(document).ready(function() {
function loop() {
var fadeTime = 1000;
var delayTime = 3200;
//if($('#layout4TextTitel').is(':visible') ) {
$('#layout4TextTitel').fadeOut(fadeTime, function() {
$('#layout4TextTitel').empty().html('one');
});
$('#layout4TextTitel').fadeIn(1000).delay(delayTime);
$('#layout4TextTitel').fadeOut(fadeTime, function() {
$('#layout4TextTitel').html('two').fadeIn(1000).delay(delayTime);
});
$('#layout4TextTitel').fadeOut(fadeTime, function() {
$('#layout4TextTitel').empty().html('three');
});
$('#layout4TextTitel').fadeIn(fadeTime).delay(delayTime);
$('#layout4TextTitel').fadeOut(fadeTime, function() {
$('#layout4TextTitel').empty().html('four');
});
$('#layout4TextTitel').fadeIn(fadeTime).delay(delayTime);
$('#layout4TextTitel').fadeOut(fadeTime, function() {
$('#layout4TextTitel').empty().html('five');
});
$('#layout4TextTitel').fadeIn(fadeTime).delay(delayTime);
$('#layout4TextTitel').fadeOut(fadeTime, function() {
$('#layout4TextTitel').empty().html('six');
});
$('layout4TextTitel').fadeIn(fadeTime).delay(delayTime);
// Ende for-Schleife
} // Ende loop()
for(var x = 0; x <=1000; x++) {
loop();
} // Ende for-Schleife
});
</script>
</head>
<body>
<div id="layout4TextTitel"></div>
</body>
1 Answer