Question Locked

Javascript will not work in child theme with wordpress

0 helpful
5 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

Hi, could anybody help me figure out why javascript code will not work.
I have put the javascript code in custom-script.js in a child theme, called twentythirteen-child.
And have enqueued it in functions.php and put the html on the wordpess page.
Here is the javascript code:

let counterDisplayElem = document.querySelector('.counter-display');
let counterMinusElem = document.querySelector('.counter-minus');
let counterPlusElem = document.querySelector('.counter-plus');

let count = 0;

updateDisplay();

counterPlusElem.addEventListener("click",()=>{
count++;
updateDisplay();
}) ;

counterMinusElem.addEventListener("click",()=>{
count--;
updateDisplay();
});

function updateDisplay(){
counterDisplayElem.innerHTML = count;
};

here is the enqueued code in functions.php:

and here is the html in worpress page:

(..)

5 replies

by spencer1621515293

Hi, I am doing what it says on your link, but I just can't seem to get any javascript to work.
I have put a clock on now. The css works fine in the child theme, but am I enqueung it correctly. Please tell me here where I have gone wrong with enqueung in functions.php.

Here is the code in functions.php:

by rproffitt

It's apparent you need to hire or outsource this work. The code tests I noted are easy to use and for all web masters I've worked with they were able to run the tests and use the results to fix or improve their code.

This didn't happen here so I am left to guess you need more time to take more classes or tutorials. OR just find others to code it up for you. As a rule I don't code for free. I will offer how I find bugs, point out or correct a bad line or two but beyond that I expect the code/web owner to put in the work.

Yes that upsets some but hey, this is all free stuff.

This discussion is closed to new replies.