I am trying to work on a project right now using node js and html. Unfortunately, i've been struck to a problem for 2 hours and i cannot figure out how to solve it.
Everytime i tried to launch the project, i got this error :
ReferenceError: document is not defined
Here is my code :
const getElement = id => document.getElementById(id);
const setVisible = (el, state) => {
let element = el;
if (typeof el === 'string') {
element = getElement(el);
}
element.style.display = state ? 'block' : 'none';
};
const setRowVisible = (row, state) => {
row.style.display = state ? 'block' : 'none';
};
module.exports = {
getElement,
setVisible,
setRowVisible,
};
Thank you for your help !