I'm getting the values of several <div>
s with the same class name and trying to play to an array in jQuery, but as I'm starting in the language I'm not getting it, I already searched the internet and nothing I found gave me a solution .
As an example:
var array = [];
var count = $('.card-header').length;
var name = $('.card-header').text();
var i, proximo;
for (i = 0; i < count; i++) {
proximo = array.length;
array[proximo] = name;
}
$('.rodapeCat').text(array);
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.2.3/jquery.min.js"></script><spanclass="card-header">Casa</span><br>
<span class="card-header">Porta</span><br>
<span class="card-header">Janela</span><br>
<span class="card-header">Escada dos fundos</span><br>
<hr/>
<!--DIV apenas para mostrar se os valores Casa, Porta, Janela, Escada dos fundos estão na array-->
<div class="rodapeCat"><div>
I wanted the array to look like this: ['Casa', 'Porta', 'Janela', 'Escada dos fundos']
.
Would anyone have any light for my problem?