I am trying to develop a kind of slideshow to an specifi application. I am having some problems with the incremetation of the div to be shown. I need to pass the selector with its position, and so increment its position.
Check the code of what I need to do:
HTML:
<div name="div-default" class="title-result">
<?php
echo "$name";
?>
</div>
<div name="div01" id="div01" class="title-result">
<?php
echo "Seu número de Personalidade é: $numerologia[0]";
?>
</div>
<div name="div02" class="title-result">
<?php
echo "Seu número de Destino é: $numerologia[1]";
?>
</div>
<div name="div03" class="title-result">
<?php
echo "Seu número de Lição de Vida é: $numerologia[2]";
?>
</div>
<div>
<button onclick="mudarDivNext([name ^= div0]:nth-child(SEND_ITS_POSITION_HERE))" id="next" class="change-div"></button>
</div>
CSS:
//here i define that the first div is visible, and the next ones invisible
div[name ^= div0]:nth-child(2){
display: inherit;
}
div[name ^= div0]{
display: none;
}
Javascript:
//This script already works for a fix position (from 2 for 3, for example) - need to make it work for all the divs.
function mudarDivNext(){
var n = 2;
$("[name ^= div0]:nth-child("+n+")").css("display", "none");
$("[name ^= div0]:nth-child("+(n+1)+")").css("display", "inherit");
}