I have a list of 200 lines, and each line has its id.
I would like to capture with the javascript, the id of each line when descending the page.
The list is set up like this:
<ol id="noticias">
<li id="geral" class="area">
Conteudo
</li>
<li id="esportes" class="area">
Conteudo
</li>
<li id="mundial" class="area">
Conteudo
</li>
<li id="tecnologia" class="area">
Conteudo
</li>
</ol>
Trying to explain otherwise.
I've mounted an array, in which, each entry represents a row in my list. In each entry there are two fields, one with the height of the line and another with the id of the line.
You're like this:
var lists = [45, 'news'], [50, 'technology'], [100, 'world'] ];
For each page scroll, the program captures the height of the body, and with the value of the height of the body, it analyzes in which field I am in the array
Solution:
I got it by using this function:
$(window).on("scroll resize", function() {
var altura_body = $(window).scrollTop();
for (var i = 0; i <= numero_de_linhas; i++) {
if (altura_body >= listas[i][0] && altura_body <= listas[i + 1][0]) {
$(".mostra_id").html(listas[i][1]);
}
}
});