I'm doing a small test page in html, js, css and I have some pictures that when I pass the mouse I want the button to be added to erase each image and when it is not on the image disappears, I managed to make the event clear with mouseover and mouseout the problem is that when I pass over the image and the button appears to erase it, the image is disconnected from the others. As an achievement, they do not move and only the button appears.
function crearAlbum(imge, nomb, ide) {
id++;
var divColumnas = document.createElement('div');
divColumnas.className = "columnas";
var divContenido = document.createElement('div');
divContenido.className = "contenido";
divContenido.id = ide;
var divBotton = document.createElement('div');
divBotton.className = 'divBorrar';
var img = document.createElement('img');
img.src = imge;
var p = document.createElement('p');
p.textContent = nomb;
var buttonBorrar = document.createElement('button');
buttonBorrar.className = 'buttonBorrar';
buttonBorrar.textContent = "X";
buttonBorrar.id = id;
buttonBorrar.addEventListener('click', borrarFoto);
buttonBorrar.style.display = 'none';
divContenido.addEventListener('mouseover', function() {
buttonBorrar.style.display = 'block';
});
divContenido.addEventListener('mouseout', function() {
buttonBorrar.style.display = 'none';
});
divBotton.appendChild(buttonBorrar);
divContenido.appendChild(img);
divContenido.appendChild(p);
divColumnas.appendChild(divContenido);
divColumnas.appendChild(divBotton);
contenedorFotos.appendChild(divColumnas);
$('.contenido').click(function() {
console.log("vistaAlbums");
var id = $(this).attr("id");
console.log(id);
window.open("albums.html?" + models + id, "_self", true);
});
}
//Mostrar texto de imagen cargada
$('#file_1').on('change', function() {
$('#inputval').text($(this).val());
});
var fileButton = document.getElementById('file_1');
fileButton.addEventListener('change', function(e) {
//Obtener archivo
file = e.target.files[0];
});
//function cerrarFormulario() {
var cerrar = $('#cerrar').click(function() {
var fade = document.getElementById('fade');
fade.style.display = 'none';
});
//} //cerrarFormulario
.divBorrar {
.buttonBorrar {
width: 13px;
height: 15px;
position: relative;
left: 198px;
bottom: 259px;
font-size: 8px;
cursor: pointer;
}
}