/html-dom /Basic
GitHub 4932★

Toggle an element

To toggle the element, we update the display property:

const toggle = function (ele) {
const display = ele.style.display;
ele.style.display = display === 'none' ? 'block' : 'none';
};

See also

Follow me on and to get more useful contents.