I would need to delete or leave the empty texts of a DIV or a P when pressing a delete button.
In the following code, what it does is from a SELECT I bring data from a database, and when selecting a surname it shows me data in ones <p>
with its ID , and when I press the delete button it deletes what I selected in SELECT perfectly , but at select another to delete DOES NOT DELETE ME , the previous data remains.
What will be wrong?
code in js
function EliminarSeleccionado() {
//capta lo que selecciono
var select = document.getElementById('buscarporapellido');
//boton Eliminar
var delButton = document.getElementById('btnEliminar');
function remove() {
value = select.selectedIndex;
select.removeChild(select[value]);
}
//remueve lo seleccionado dentro del SELECT
delButton.onclick = remove;
//vacia el contenido de los <p>
$("#Principalfide").empty();
$('#PrincipalLetra').empty();
}