forked from anmolp476/OpticGenie
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdomScript.js
More file actions
28 lines (24 loc) · 916 Bytes
/
Copy pathdomScript.js
File metadata and controls
28 lines (24 loc) · 916 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
const fileInput = document.getElementById("fileInput");
const processButton = document.getElementById("processButton");
const imageContainer = document.getElementById("image-box");
const grid = document.getElementById("grid-container");
processButton.addEventListener('click', function(){
//alert("button clicked")
for(let i = 0; i < 4; i++){
const file = fileInput.files[i];
const reader = new FileReader();
let divR = document.createElement('div');
divR.classList.add("recipe-grid");
reader.onload = function () {
divR.innerHTML = `<img src="${reader.result}" style="max-width: 150px; max-height: 150px; float: left; object-fit:cover;" />`;
};
reader.readAsDataURL(file);
grid.appendChild(divR);
}
});
fileInput.addEventListener('change', function(){
let divs = document.querySelectorAll(".recipe-grid");
for(let div of divs){
div.remove();
}
});