I am changing the img src to create a sort of slideshow, i want the text under my photos to change depending on the src, i tried with replacewith() but it is not working, someone can help? that would be rrreeeeaaaly nice!
<script>
$(document).ready(function(){
var image_tracker='36'
function slide()
{
var image = document.getElementById('intro');
if(image_tracker==='36')
{
image.src='galerie/37l.jpg';
image_tracker='37';
}
else if(image_tracker=='37'){
image.src='galerie/38l.jpg';
image_tracker='38';
}
else if(image_tracker==='38'){
image.src='galerie/39l.jpg';
image_tracker='39';
}
else if(image_tracker==='39'){
image.src='galerie/40l.jpg';
image_tracker='40';
}
else if(image_tracker==='40'){
image.src='galerie/41l.jpg';
image_tracker='41';
}
else if(image_tracker==='41'){
image.src='galerie/42l.jpg';
image_tracker='42';
}
else if(image_tracker==='42'){
image.src='galerie/43l.jpg';
image_tracker='43';
}
else if(image_tracker==='43'){
image.src='galerie/44l.jpg';
image_tracker='44';
}
else if(image_tracker==='44'){
image.src='galerie/45l.jpg';
image_tracker='45';
}
else if(image_tracker==='45'){
image.src='galerie/46l.jpg';
image_tracker='46';
}
else{
image.src==='galerie/backintroju.jpg';
image_tracker='36';
}}
var b = window.setInterval('slide()',1500);
</script>
<body>
<div id='photos'><img src='galerie/backintroju.jpg'id='intro'class='responsivegal'/></div>
<div id='infosphotos' class='t37'>08:55am July 25 2015, <b id='urk'>Urk </b> (The Netherlands)</div>
<div id='boutondroite'> <a href='l37.html'><img src='image1/droite.png'class='responsivebouton'/></a> </div>
<div id='fermer'><a href='photos.html'><img src='image1/fermer3.png'class='responsivebouton'/></a></div>
</body>
You can change the contents of any element with the innerHTML
property.
<div id="foo">
First this text
</div>
This will render just the line 'First this text', though with this script
<script>
document.getElementById("foo").innerHTML = "Now this text";
</script>
the line 'Now this text' will be rendered. Just decide when you execute the line of code.