Show checkbox selected at the top of the table

0

I have a table in which I can select several rows by selecting several checkboxes using JQuery and filling the table dynamically, what I need is that each time I select a checkbox it is shown at the beginning of the table.

I would like to have something similar to the table in the following link link

But my table is made with bootstrap and not in DataTables

This table is filled with a Node.js service Table HTML code:

table#tabla1.table.table-hover(style='font-size:12px;')
thead
  tr
    th Campo 1
    th Campo 2
    th Campo 3


tbody(style='background-color:rgb(245,245,245);')
  each p in datos.p
    tr
      td.numero
          input.checkpres(data-fkp=''+p.fkp,type='checkbox', value='#{p.fkc}')
      td #{p.campo2}
      td #{p.campo3}

With this code I get the selected checkboxes to manipulate them, insert them in a BD JQuery code.     var selected = new Array ();

        $('.checkpres:checked').each(function() {                
            seleccionados.push([$(this).val(),$(this).attr('data-fkp')
            ]); 
        });
        console.log(seleccionados);

And what I need is every time I select a checkbox to be positioned at the beginning of the table or also to show me only the selected ones

This is the resulting table

    
asked by danoniya 28.06.2018 в 23:59
source

0 answers