dimanche 13 octobre 2019

not getting random text from array in javascript

I am not good at javascript. :(

After picking out a random text from an array it doesnt randomize the second slide etc.... Its just stays the same as the first random text. Where is my mistake?

<script type="text/javascript">

var r_text = new Array ();
r_text[0] = "Text A";
r_text[1] = "Text B";
r_text[2] = "Text C";
r_text[3] = "Text D";
r_text[4] = "Text E";
var i = Math.floor(7*Math.random())


</script> 
<div class="swiper-container">
<div class="swiper-wrapper"> 
                        
<div class="swiper-slide"> 
<script type="text/javascript">document.write('<span>' + r_text[i] + '</span>');
</script>
<div>

<div class="swiper-slide"> 
<script type="text/javascript">document.write('<span>' + r_text[i] + '</span>');
</script>
<div>
   
</div>     
</div>  
</div> 
</div>



Aucun commentaire:

Enregistrer un commentaire