Validate script in amp

29 Views Asked by At

How could I get the following script to validate AMP?

<script>
    document.addEventListener("DOMContentLoaded", function () {
        var toggleTOC = document.getElementById('toggleTOC');
        var tocList = document.querySelector('.toc_list');

        toggleTOC.addEventListener('change', function () {
            // Cambia la altura de .toc_list al estado actual del checkbox
            tocList.style.height = toggleTOC.checked ? 'auto' : '134px';
        });

        // Agrega un evento de clic a .toc_list para expandir/cerrar cuando se hace clic en la flecha
        tocList.addEventListener('click', function () {
            toggleTOC.checked = !toggleTOC.checked;
            // Dispara el evento change para activar la lógica de expansión/cierre
            var event = new Event('change');
            toggleTOC.dispatchEvent(event);
        });
    });
</script>

Thanks

Functional code but not valid in amp

0

There are 0 best solutions below