0
Good people.
I have a dynamic array that receives associated data in buttons where it should index to each interaction the values (0, 1, 2, 3...). The problem is that the index value persists at zero (0) ? Follow the code :
$(document).ready(function() {
// method click(action: atribui valores as variaveis declaradas:)
$(".btn_data_add").click(function() {
// method .attr(action: retorna o valor do atributo) :
var $ws_item_in = $(this).attr("data-item");
var $ws_price_in = $(this).attr("data-price");
var $ws_icon_in = '<a class="waves-effect waves-red btn-flat btn_data_rem"><i class="material-icons">delete_outline</i></a>';
// estrutura colunas de uma linha de tabela html :
var $ws_row_open = '<tr>';
var $ws_col_item = '<td class="fontype-2 $ws_item_out">' + $ws_item_in + '</td>';
var $ws_col_price = '<td class="fontype-2 $ws_price_out">' + $ws_price_in + '</td>';
var $ws_col_icon = '<td class="fontype-2">' + $ws_icon_in + '</td>';
var $ws_row_close = '</tr>';
// estrutura linha da tabela html :
var $ws_row_in = $ws_row_open + $ws_col_item + $ws_col_price + $ws_col_icon + $ws_row_close;
// organiza indexando dentro de uma array :
var $ws_array_row = [$ws_row_in];
//
for(var i=0; $ws_array_row.length; i++) {
//
console.log(i, $ws_array_row[i]); // i é o índice, matriz[i] é o valor
break;
}
});
});
Didn’t work ? Continues to index the value zero (0) to variable face added !
– João Carlos
The problem was that the array was inside the event . click(), needs to be declared outside and at the beginning. Thanks for the force !
– João Carlos