samedi 22 juin 2019

JavaScript function not called on page load

I have a JavaScript function placed at the bottom of my page but for some reason the page isn't called on page load. I tried running it on console to be sure it doesn't produce an error, but it ran perfectly fine. I even tried setting the

window.onload = function() {applyMovement();}

That didn't even work.

about.js

function applyMovement() {
    let bars = document.getElementsByClassName('progress-bar');
    for (let i = 0; i < bars.length; i++) {
        moveBar(bars[i], i);
    }
}

index.blade.php

...
</body>
<script src="">window.onload = function() {applyMovement();} </script>
</html>

It should be noted that I am using Laravel 5.8. I've placed my JS file inside the public directory. Also other actions on the file are being ran but not this patricular function.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire