Afbeelding 'fadet' maar tot afbeelding 2 i.p.v. afbeelding 5

Status
Niet open voor verdere reacties.

jorenman

Gebruiker
Lid geworden
27 jul 2013
Berichten
222
HTML:
<!doctype html>
<html>
<head>
<title>Veranderende afbeelding</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<link rel="stylesheet" type="text/css" href="style.css">
<script type="text/javascript">
     $(document).ready(function(){
	     slideShow();
	 });
	 
	 function slideShow(){
	     var showing = $('#wrap .is-showing');
		 var next = showing.next().length ? showing.next(): showing.parent().children(':first');
         showing.fadeOut(800, function(){
	     next.fadeIn(800).addClass('is-showing');
	 })
	 .removeClass('.is-showing');
     
	 setTimeout(slideShow, 5000);	 
	 }
    
</script>
</head>
<body>
     <div id="wrap">
         <img src="slide1.jpg" width="960" height="375" alt="image 1" class="is-showing" /> 
		 <img src="slide2.jpg" width="960" height="375" alt="image 2" /> 
		 <img src="slide3.jpg" width="960" height="375" alt="image 3" /> 
		 <img src="slide4.jpg" width="960" height="375" alt="image 4" /> 
		 <img src="slide5.jpg" width="960" height="375" alt="image 5" /> 
	 </div>
</body>
</html>

HTML:
#wrap {
margin-top: 0px;
margin-right: auto;
margin-bottom: 0px;
margin-left: auto;
height: 375px;
width: 960px;
overflow: hidden;
}
#wrap img {
display: none;
}
#wrap .is-showing {
display: inline;
}

Dit is een HTML (met Javascript erin) bestand en een CSS bestand.
Dit is gemaakt voor het veranderen van een afbeelding met een totaal van 5 afbeeldingen.
Alleen mijn veranderende afbeelding komt niet verder dan afbeelding 2.
Hij gaat van afbeelding 1 naar afbeelding 2 en dan van afbeelding 2 weer naar afbeelding 2.
Hoe zorg ik ervoor dat ie van afbeelding 2 naar afbeelding 3 en van afbeelding 3 naar afbeelding 4 en zo voort?

P.S. Weet iemand nog of er een tutorial is om het te krijgen net zoals hier: http://www.google.nl/intl/nl/mail/help/about.html
 
Hallo hallo...
met mijn beperkte kennis wil ik toch proberen om te helpen...

moet de vermelding naar " class="is-showing" " niet bij elke img staan?
 
Wat doet deze code allemaal?
[js]
function slideShow(){
var showing = $('#wrap .is-showing');
var next = showing.next().length ? showing.next(): showing.parent().children(':first');
showing.fadeOut(800, function(){
next.fadeIn(800).addClass('is-showing');
})
.removeClass('.is-showing');
[/js]
 
Ja die snapte ik dus ook niet.
Ik heb heel de code van een tutorial.
 
Sorry maar hoe verwacht je een website te kunnen maken zonder te weten hoe "het internet" werkt?

Er zijn honderden websites te vinden waar je zo code vandaan kunt halen en in een pagina zetten, maar als je niet begrijpt wat ze doen gaat het nooit werken.

Daarnaast, als dit onderdeel van een tutorial is, dan is het A een slechte tutorial want hij bevat foute code of B je hebt hem niet goed gevolgd.

Ga eerst eens na wat er op elke regel gebeurd zodat je begrijpt wat de code doet, er wordt gebruik gemaakt van jQuery dus ook daar zul je kennis van moeten hebben.
 
Ik ben zelf al pittig goed in HTML en CSS.
Nu ben ik basis Javascript en jQuery aan het doen, wat hartstikke goed gaat.
Ik weet wel hoe het internet werkt.
Dit heb ik zelf gemaakt:
HTML:
<?php
?>
<!DOCTYPE HTML>
<html>
<head>
<title>Silverworx Nederland | Home</title>
<link rel="stylesheet" type="text/css" href="style.css">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script type="text/javascript">
     $(document).ready(function(){
		 $("#image2").hide();
		 $("#image3").hide();
		 $("#image4").hide();
		 $("#image5").hide();
	 }); 
	$(document).ready(function(){
         $("#image1").click(function(){
             $("#image1").fadeOut(function(){
			     $("#image2").slideDown(); 
             })			 
         })		 
     });
	 $(document).ready(function(){
         $("#image2").click(function(){
             $("#image2").fadeOut(function(){
			     $("#image3").slideDown(); 
             })			 
         })		 
     }) ;
	 $(document).ready(function(){
         $("#image3").click(function(){
             $("#image3").fadeOut(function(){
			     $("#image4").slideDown(); 
             })			 
         })		 
     }); 
	  $(document).ready(function(){
         $("#image4").click(function(){
             $("#image4").fadeOut(function(){
			     $("#image5").slideDown(); 
             })			 
         })		 
     });
	 $(document).ready(function(){
         $("#image5").click(function(){
             $("#image5").fadeOut(function(){
			     $("#image1").slideDown(); 
             })			 
         })		 
     });
	 $(document).ready(function(){
	     $(".rounded1").mouseenter(function(){ 
             $('.rounded1').fadeTo(500, 0.5);
		 })
	})	
 $(document).ready(function(){
	     $(".rounded1").mouseleave(function(){ 
             $('.rounded1').fadeTo(500, 1);
		 })
	})	
	  $(document).ready(function(){
	     $(".rounded2").mouseenter(function(){ 
             $('.rounded2').fadeTo(500, 0.5);
		 })	 
	 })
	  $(document).ready(function(){
	     $(".rounded2").mouseleave(function(){ 
             $('.rounded2').fadeTo(500, 1);
		 })
	})	
 
	  $(document).ready(function(){
	     $(".rounded3").mouseenter(function(){ 
             $('.rounded3').fadeTo(500, 0.5);
		 })	 
	 })
	 $(document).ready(function(){
	     $(".rounded3").mouseleave(function(){ 
             $('.rounded3').fadeTo(500, 1);
		 })
	})
</script>
<?php
include "inc/tags.php"
?>
</head>
<body>

<div id="header">
<div id="logo">     
<a href="http://www.silverworx.nl"><img src="silverworxhome.png" width="100%" height="45px"></img></a>
</div>
     
	 <div id="navmenu">
	     <ul>
		     <li class="webdesign"><a href="/design/index.html">Webdesign</a></li>
			 <li class="webhosting"><a href="/hosting/index.html">Webhosting</a></li>
			 <li class="overons"><a href="about.php">Over ons</a></li>
			 <li class="contact"><a href="contact.php">Contact</a></li>
		</ul>
	 </h1>	
     </div>	 
</div>
<div id="body">
     <div id="wrap">
         <img src="slide1.jpg" width="100%" height="375" id="image1">
		 <img src="slide2.jpg" width="100%" height="375" id="image2">
		 <img src="slide3.jpg" width="100%" height="375" id="image3">
		 <img src="slide4.jpg" width="100%" height="375" id="image4">
		 <img src="slide5.jpg" width="100%" height="375" id="image5">
	 </div>
	 <div id="tekstkop">
	     <h1>Tekstkop</h1>
	 </div>
	 <div id="kop">
	     <h2>Kop</h2>
	 </div>
	 <div id="roundedcorners">
	     <div class="rounded1">
	     </div>
	     <div class="rounded2">
	     </div>
	     <div class="rounded3">
	     </div>
	 </div>
	 <div id="boxes">
	     <div class="box1">
		     <div class="topbox">
			 Webdesign
			 </div>
			 <div class="contentbox">
			 Hier staat de content. Ik moet nog wel instellen als je met je muis van de rondjes afgaat, dat de vervaging dan ook weg gaat.
			 </div>
	     </div>
	     <div class="box2">
		     <div class="topbox">
			 Webhosting
			 </div>
			 <div class="contentbox">
			 hier staat de content
			 </div>
	     </div>
	     <div class="box3">
		     <div class="topbox">
			 Webservice
			 </div>
			 <div class="contentbox">
			 hier staat de content
			 </div>
	     </div>
	 </div>
</div>
<div id="footer">
     <div id="links">
	 © Silverworx 2014 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="#">Webdesign</a> | <a href="#">Webhosting</a> | <a href="#">Webservice</a> | <a href="#">Over ons</a> | <a href="#">Contact</a>
	</div>
	 <div id="logo2">
	 </div>
	
</div>

</body>
</html>

HTML:
html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, img, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, b, u, i, center, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, embed, figure, figcaption, footer, header, hgroup, menu, nav, output, ruby, section, summary, time, mark, audio, video {
 margin: 0;
 padding: 0;
 border: 0;
 font-size: 100%;
 font: inherit;
 vertical-align: baseline;
 }
body {
margin: 0;
}
p {
margin: 0;
}
#header {
margin: 0;
height: 60px;
width: 100%;
background: #fff;
color: #fff;
float: left;
border-bottom: 1px solid #000;
}
#logo {
margin-top: 5px;
margin-left: 15px;
height: 45px;
width: 32%;
float: left;
}
#navmenu {
margin-left: 52%;
margin-top: 5px;
padding: 0;
width: 47%;
height: 45px;
}
#navmenu ul {
padding: 0;
margin-top: 10px;
list-style: none;
}

#navmenu ul li a {
color: #909090;
text-decoration: none;
display: block;
font-family: Verdana;
}
#navmenu a:hover {   
    border-bottom: 1px solid #000;
    padding-bottom: 2px;
	color: #000;
}
#navmenu .webdesign {
font-weight: bold;
text-transform: uppercase;
letter-spacing: 1px;
margin-left: .1%;
width: 21%;
padding: 10px;
text-align: center;
float: left;
}
#navmenu .webhosting {
font-weight: bold;
text-transform: uppercase;
letter-spacing: 1px;
margin-left: .1%;
width: 21%;
padding: 10px;
text-align: center;
float: left;
}
#navmenu .overons {
font-weight: bold;
text-transform: uppercase;
letter-spacing: 1px;
margin-left: .7%;
width: 18%;
padding: 10px;
text-align: center;
float: left;
}
#navmenu .contact {
font-weight: bold;
text-transform: uppercase;
letter-spacing: 1px;
margin-left: 1.3%;
width: 15%;
padding-top: 10px;
padding-left: 0px;
text-align: center;
float: left;
}

#body {
margin: 0;
width: 100%;
float: left;
}
#wrap {
margin: 30px auto;
height: 360px;
width: 80%;
}
#tekstkop {
margin-top: 30px;
height: 100px;
background: #555;
width: 100%;
}
h1 {
font-family: Verdana;
font-size: 50px;
text-align: center;
}
#kop {
margin: 0;
height: 40px;
width: 100%;
border-top: 1px solid #000;
border-bottom: 1px solid #000;
}
h2 {
font-family: Verdana;
font-size: 25px;
text-align: center;
}
#roundedcorners {
margin-top: 10px;
width: 100%;
float: left;
border: 1px solid #000;
}
 .rounded1, .rounded2, .rounded3 {
 margin-top: 10px;
 margin-left: 14%;
 height: 200px;
 width: 15%;
 border-radius: 100px;
 float: left;
 }
.rounded1 {
background: blue;
}
.rounded2 {
background: red;
}
.rounded3 {
background: green;
}
#boxes {
margin: 0;
width: 100%;
border: 1px solid #000;
}
.box1, .box2, .box3 {
margin-top: 10px;
margin-left: 13%;
 height: 200px;
 width: 17%;
 float: left;
 }
 .box1 {
 margin-left: 13%;
 }
 .box2 {
 margin-left: 11.5%;
 }
 .box3 {
 margin-left: 12.5%;
 }
 .topbox {
 margin: 0;
 height: 50px;
 width: 100%;
 font-family: Verdana;
 font-size: 25px;
 text-align: center;
 }
 .contentbox {
     margin-left: 5%;
	 height: 150px;
	 width: 100%;
 }
#footer {
margin-top: 10px;
height: 100px;
width: 100%;
color: #fff;
background: #1C1C1C;
float: left;
font-family: Verdana;
}
#links {
margin-top: 50px;
margin-left: 5%;
height: 30px;
width: 60%;
float: left;
}
#links a {
color: #fff;
text-decoration: none; 
}
#links a:hover {
text-decoration: underline;
}
#logo2 {
margin-top: 48px;
margin-left: 77%;
border: 1px solid #fff;
height: 50px;
width: 22%;
}

Dit is een HTML (met Javascript erin) en een CSS bestand.
Bovenaan de body heb ik gezorgd voor een slideshow.
Alleen het werkt pas als je op het plaatje klikt.
Weet iemand hoe je er een timer op kan zetten?
Dat ie om de 5 seconden ofso van plaatje wisselt?
 
Nu kom je alweer met volledig andere code ten opzicht van het vorige bericht, terwijl daar eigenlijk vrij weinig aan mankeert. :(

Deze manier van scripten is niet de bedoeling en bevestigt mijn uitspraak dat je niet begrijpt wat het doet:
[js]
$(document).ready(function(){
$("#image2").hide();
$("#image3").hide();
$("#image4").hide();
$("#image5").hide();
});
$(document).ready(function(){
$("#image1").click(function(){
$("#image1").fadeOut(function(){
$("#image2").slideDown();
})
})
});
$(document).ready(function(){
$("#image2").click(function(){
$("#image2").fadeOut(function(){
$("#image3").slideDown();
})
})
}) ;
$(document).ready(function(){
$("#image3").click(function(){
$("#image3").fadeOut(function(){
$("#image4").slideDown();
})
})
});
$(document).ready(function(){
$("#image4").click(function(){
$("#image4").fadeOut(function(){
$("#image5").slideDown();
})
})
});
$(document).ready(function(){
$("#image5").click(function(){
$("#image5").fadeOut(function(){
$("#image1").slideDown();
})
})
});
$(document).ready(function(){
$(".rounded1").mouseenter(function(){
$('.rounded1').fadeTo(500, 0.5);
})
})
$(document).ready(function(){
$(".rounded1").mouseleave(function(){
$('.rounded1').fadeTo(500, 1);
})
})
$(document).ready(function(){
$(".rounded2").mouseenter(function(){
$('.rounded2').fadeTo(500, 0.5);
})
})
$(document).ready(function(){
$(".rounded2").mouseleave(function(){
$('.rounded2').fadeTo(500, 1);
})
})

$(document).ready(function(){
$(".rounded3").mouseenter(function(){
$('.rounded3').fadeTo(500, 0.5);
})
})
$(document).ready(function(){
$(".rounded3").mouseleave(function(){
$('.rounded3').fadeTo(500, 1);
})
})
[/js]

$(document).ready() wordt uitgevoerd wanneer het document klaar met laden is.
Dat gebeurd dus maar één keer, waarom je het vervolgens overal maar voor gebruikt is mij een raadsel. :confused:

Verder hoor je elke regel met een ; af te sluiten, dat gebeurd ook niet consequent.

Een wel bekend principe binnen programmeren is DRY; Don't Repeat Yourself.
Heb je een boel code die hetzelfde doet maar net iets anders dan kun je beter kijken hoe je dat kunt optimaliseren.

Je kunt een bepaalde functie om de x milliseconden uit laten voeren via de Javascript functie setInterval(functie, milliseconden);

In plaats van steeds maar weer wat anders proberen omdat het niet werkt lijkt het mij verstandiger dat je gaat kijken waarom iets niet werkt, wat doet een regel code of wat juist niet? Wat verwacht je dat een bepaalde regel code doet?

Je vorige code was simpel en doeltreffend alleen die bevatte één fout, ga eens met die code verder en probeer te achterhalen wat de code moet doen en wat er nu misgaat.
 
Status
Niet open voor verdere reacties.
Terug
Bovenaan Onderaan