How do I get an element by id in javascript, kinda like this:
document.getElementById('assistance').style.display = 'none';
If the element id is defined in twig like this:
<div id="assistance-{{ key }}">
How do I get an element by id in javascript, kinda like this:
document.getElementById('assistance').style.display = 'none';
If the element id is defined in twig like this:
<div id="assistance-{{ key }}">
Assuming that
id starting with assistance and id will be generatedYou can use document.querySelector with attribute-starts-with match
document.querySelector('[id^="assistance--"]').style.display = 'none';