1
I do this query in the database to list all the names of the registrations...
$('.ordenar').click(function(){
db.transaction(function(tx){
tx.executeSql('SELECT nome FROM cartoes', [], function(tx,results){
for(i=0; i<results.rows.length; i++){
console.log(results.rows.item(i).nome);
//Aqui ele me retorna todos os nomes dos cadastros existentes, exemplo:
//nomecadastro1
//nomecadastro2
//e assim sucessivamente..
}
});
});
});
These registrations are entered through an append, this way:
$(".listagem").append(
`<div class="row" id="corpo-cartoes">
<div class="col s12 m7" style="width: 100%;">
<div class="card">
<a href="cartao.html#${lastId}">
<div class="card-image">
<div class="gradient-cartao-lista"></div>
<img src="${capa}">
<span class="card-title"><h1>${data.card.empresa}</h1><p>${data.card.code}</p></span>
</div>
</a>
<div class="card-action icone-meu-cartao">
<a href="#"><i class="material-icons">star</i></a>
<a href="#"><i class="material-icons">crop_free</i></a>
<a href="#"><i class="material-icons">visibility</i></a>
<a href="cadastro-cartao.html#${lastId}"><i class="material-icons btn-editar">edit</i></a>
</div>
</div>
</div>
</div>`
);
Visually they look like this:
I created A first, then B...
Therefore, it must be reversed, the B must be before the A.
Soon, how could I order them through the result?
I would like to sort them by the recently added ones, that is, from the last record to the first. How could I do this with Javascript/Jquery?
No use ordering straight in
query
?– Sorack
Pq does not sort the list with CSS ?
– hugocsl
Change your sql command to sort by some specific column and add the
desc
in front to be reverse ordering– Victor Laio