1
I need to create a loop so I can feed it a graphic.
while($(".previsto").eq(0).text(),){}
I need to take these values eq(0), eq(1), eq(2)...
$(".previsto").eq(0).text(),
$(".previsto").eq(1).text(),
$(".previsto").eq(2).text(),
...
1
I need to create a loop so I can feed it a graphic.
while($(".previsto").eq(0).text(),){}
I need to take these values eq(0), eq(1), eq(2)...
$(".previsto").eq(0).text(),
$(".previsto").eq(1).text(),
$(".previsto").eq(2).text(),
...
0
To get the element indices (from first to last), the loop variable must start at 0
up to the number of elements -1:
for(var i = 0; i < $(".previsto").length; i++){
console.log($(".previsto").eq(i).text());
}
The $(".previsto").length
returns the number of elements with the class .previsto
, and the variable i
must start 0
as long as it is less than $(".previsto").length
.
Browser other questions tagged javascript jquery loop for chartjs
You are not signed in. Login or sign up in order to post.
'Cause there’s a comma after the
.text()
?– Anderson F. Viana
Because this is to generate the graph, so you need the comma, I want to create a loop so that it is dynamic. eq() is like an index
– Renan Araújo
I’m trying something like :
– Renan Araújo
for(var i = i; i < ($(".predicted").eq(0).text()).length; i++){ console.log($(".predicted").eq(0).text(); }
– Renan Araújo
I stored the result of a Divs Query inside a loop in php, I need to take the values of these Divs, so the selector is a "." class. I need a loop to take the values of the div " $(".predicted"). eq(0). text();" using this eq function()
– Renan Araújo
Try it this way:
for(var i = 0; i < $(".previsto").length ; i++){ console.log($(".previsto").eq(i).text()); }
– Sam
Our partner, it worked. Mt thank you
– Renan Araújo