How to page text with JQuery? I have a large text of about 5000 characters and I need to make it stay in about 5 pages with the option of NEXT PAGE and PREVIOUS PAGE, I researched and found no tutorial on the subject, only plugins that do this, can anyone help me? >
I started the script but my weak programming logic did not let me proceed ... Here's what I have:
<script>
$(document).ready(function() {
var pagina = 1;
var texto2 = $("#none").val().toString();
var len = texto2.length;
if (len > 800 || len < 1600)
{
var len = texto2.slice(0, 800);
var len2 = texto2.slice(800, 1600);
var len3 = texto2.slice(1600, 2400);
var len4 = texto2.slice(2400, 3000);
}
var paginatotal = 1;
$("#divtest").append(len);
});
$("#divtest2").click(function() {
if (pagina <= paginatotal)
{
var pagina = pagina + 1;
}
else
{
var pagina = paginatotal;
}
});
$("#divtest3").click(function() {
if (pagina > 1)
{
var pagina = pagina - 1;
}
else
{
var pagina = 1;
}
});
</script>
<textarea id="none" style="display: none;"><?php echo $row[texto]; ?></textarea>
<hr><div id="divtest"></div>
<BR><div id="divtest2">proxima</div><div id="divtest3">anterior</div>
Probably to proceed, I need to create a for loop in place of the IF with the slices ... but I caught ...