I want to add the filters css I have every time I click on the photos, I want to apply the original photo to the original photo with this ID at any time.
<img src="./assets/img/template.jpg" alt="none" />
none
<img
id="grayscale"
src="./assets/img/template.jpg"
alt="grayscale"
/>
grayscale
---- css
#grayscale {
filter: grayscale(1);
}
#sepia {
filter: sepia(1);
}
#invert {
filter: invert(1);
}
#blur {
filter: blur(2px);
}
#saturate {
filter: saturate(2);
}
#contrast {
filter: contrast(2);
}
const handleFilter = (e) => {
const { target } = e;
const { id: filter } = target;
// filter: "grayscale" | "sepia" | "invert" | "hue-rotate" | "contrast" | "saturate" | "blur"
};
You need to add a id in your div
document.getElementById('#yourId').style.property = new style