I'm currently working on a challenge involving creating an array of images using an input field and then displaying the array of images as a slider in JavaScript. If anyone can help me, please provide a solution.
Could you kindly share the JavaScript code for this?
document.querySelector("#a").addEventListener("change", function(){
const reader = new FileReader();
reader.addEventListener("load", () => {
localStorage.setItem("recent-image", reader.result)
});
reader.readAsDataURL(this.files[0]);
});
document.addEventListener("DOMContentLoaded()", () => {
const imageurl = localStorage.getItem("recent-image");
if(imageurl){
document.querySelector("#b").setAttribute("src", imageurl);
}
});
Is it possible to achieve this with an array? Please let me know your answer.
Currently, only one image is being stored, but I would like to be able to store multiple images in local storage using an array. Can you assist me with this?