Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Crea un contador y un arreglo que almacenarà la informaciòn
- let row = 0, data = [];
- //cicla los tr unicamente del body
- $('#mytable tbody tr').each( function(){
- // Para evitar la primera fila validamos que sea mayor a 0 el row
- if( row > 0 ) {
- // Crea un objeto que te ayude a darle forma a tu informacion
- // Aprovecharemos que cada td tiene ya una clase para ir insertando la informacion
- let tr = {};
- tr.ide = $(this).find('.ide').text();
- tr.pro = $(this).find('.pro').text();
- tr.desc = $(this).find('.desc').text();
- tr.precio = $(this).find('.precio').text();
- tr.cantidad = $(this).find('.cantidad').text();
- tr.sumTotal = $(this).find('.sumTotal').text();
- // Empujamos el objeto a nuestra data
- data.push( tr );
- }
- //incrementamos el contador en 1
- row++;
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement