to clone a row or more than one depending on the checkbox
works fine but when you perform for the second time clones 2 times the same row or rows and so if they are three times then three times more the same row or rows
The question is how could I get the checkbox
of the row?
$(document).ready(documentoListo)
function documentoListo() {
$("#cartola").click(cartola)
}
function cartola(){
var result = [];
var pos = 0;
$("input[name='prestaciones[]']:checked").each(function(){
var f=null;
f=$(this).closest('tr').clone(false)
$(f).appendTo(".clon");
});
}
<!DOCTYPE html>
<html>
<head>
<title></title>
<script
src="https://code.jquery.com/jquery-3.2.1.js"
integrity="sha256-DZAnKJ/6XZ9si04Hgrsxu/8s717jcIzLy3oi35EouyE="
crossorigin="anonymous"></script>
</head>
<body>
<table id="tablaHisto" class="table table-striped"><thead><tr style="height: 60px;"><th style="width: 50%;text-align: center; background: #ccc">PRESTACIONES</th><th style="width: 50%;"><input type="text" class="form-control" id="fltro" placeholder="Escriba para filtrar"></th></tr><tr><th class="d"><input class="selTodo" name="selTodo" type="checkbox">Todo</th><th class="d">Rut socio</th><th class="d">Nombre socio</th><th class="d">Nombre carga</th><th class="d">Cargo</th><th class="d">Prestacion</th><th class="d">Fecha solicitud</th><th class="d">Monto solicitado</th></tr></thead><tbody id="overno"><tr><td class="d"><input class="prestaciones" name="prestaciones[]" type="checkbox" value="183"></td><td class="d">19.367.763-0</td><td class="d">Gallardo Perez Katerinde Del Transi</td><td class="d"></td><td class="d">Monitor De Calidad</td><td class="d">Prestamos</td><td class="d">24 / 08 / 2017</td><td class="d">100.000</td></tr><tr><td class="d"><input class="prestaciones" name="prestaciones[]" type="checkbox" value="189"></td><td class="d">15.355.239-8</td><td class="d">Duarte Briones Claudia Andrea Del C</td><td class="d"></td><td class="d">Asistente Recursos Humanos</td><td class="d">Prestamos</td><td class="d">04 / 09 / 2017</td><td class="d">50.000</td></tr></tbody></table>
<button type='button' id="cartola" class='btn btn-success' value=''>Clonar</button>
<div class="tablaExcel">
<table id="tablaHisto" class="table table-striped">
<thead>
<tr style="height: 60px;">
<th style="width: 50%;text-align: center; background: #ccc">PRESTACIONES</th>
<th style="width: 50%;"><input type="text" class="form-control" id="fltro" placeholder="Escriba para filtrar"></th>
</tr>
<tr>
<th class="d"></th>
<th class="d">Rut socio</th><th class="d">Nombre socio</th><th class="d">Nombre carga</th>
<th class="d">Cargo</th><th class="d">Prestacion</th>
<th class="d">Fecha solicitud</th>
<th class="d">Monto solicitado</th>
</tr>
</thead>
<tbody class="clon">
</tbody>
</table>
</div>
</body>
</html>