Execute code at the end of script

1 0 0

Hey! I want to do a counter, which counts a number of typed letters in the input box (Kids name).
Link for this page: https://child-universe.com/collections/name-puzzle/products/hedgehog-board-name-puzzle
It's plugin input "Best Custom Products Option". I use javascript to do this function. When I tested it in Chrome Console, it worked perfectly. But when I tried to use it in theme code, it doesn't work. I think the reason is my code is not executing at the end of the page. (I placed my code at the end of theme.liquid file and console.log some text, after I saw what my code execute at the beginning).

So, i need to addEventListener for this input. 

I do:


document.querySelector("MY INPUT").addEventListener("input", function(){
// script which count letters


After placing it in file, i got err in console.


How i can fix that, or make my code run at the end?


Replies 0 (0)