• Das Erstellen neuer Accounts wurde ausgesetzt. Bei berechtigtem Interesse bitte Kontaktaufnahme über die üblichen Wege. Beste Grüße der Admin

[FRAGE] Script (Javascript) funktioniert nicht richtig.

Dreandor

New member
Guten Tag,
Ich habe heute ein Script erstellt, was eig so funktionieren müsste. Es sollen abwechselnd zwischen 2 Bildern gewechselt werden. Die Bilder liegen beide im angegebenen Ordner, jedoch passiert nichts.

HTML:
<script>
		function thebackground() {
		$('div.background img').css({opacity: 0.0});
		$('div.background img:first').css({opacity: 1.0});
		setInterval('change()',5000); 
		}

		function change() {
		var current = ($('div.background img.show')? $('div.background img.show') : $('div.background img:first'));
		if ( current.length == 0 ) current = $('div.background img:first');
		var next = ((current.next().length) ? ((current.next().hasClass('show')) ? $('div.background img:first') :current.next()) : $('div.background img:first'));
		next.css({opacity: 0.0})
		.addClass('show')
		.animate({opacity: 1.0}, 1000);
		current.animate({opacity: 0.0}, 1000)
		.removeClass('show');
		};

		$(document).ready(function() {
		thebackground();	
		$('div.background').fadeIn(1000); 
		$('div.background img').fadeIn(1000); 
		});
</script>

<div class="background"> 
		<img src="images/Bild1.png" alt="pic1" /> 
		<img src="images/Bild2.png" alt="pic2" /> 
</div>

Und in der CSS sieht es so aus:
Code:
.gradient {
	background-image: -webkit-gradient(  linear,  left bottom,  left top,  color-stop(0.28, rgb(255,201,116)),  color-stop(0.64, rgb(228,143,10)) );
	background-image: -moz-linear-gradient(  center bottom,  rgb(255,201,116) 28%,  rgb(228,143,10) 64% );
	width:300px;
	height:150px;
	padding:5px;
}


div.background {
	position:absolute;
	left:0px;
	top:0px;
	z-index:-1;
	width: 100%;
	height: 100%;
	overflow: hidden;
}
div.background img {
	position: absolute;
	list-style: none;
	left:0px;
	top:0px;
	width: 100%;
	height: 100%;
	overflow: hidden;
}
div.background ul li.show {
	z-index:500;
	width: 100%;
	height: 100%;
	overflow: hidden;
}

Vllt kann mir jemand helfen.
 
Ich denke, dass da nichts in der Fehlerkonsole steht - jQuery hald...

Hast du einen Link, wo wir uns das live ansehen können?

PS: Du solltest dringend an deiner Codeformatierung arbeiten...
 
bei mir im chrome funktioniert es wunderbar. vor dem ersten wechsel dauert es etwas, scheint zu preloaden. hast du lange genug gewartet?

sieht übrigens nett aus!
 
Zurück
Oben