How can I apply JS code to my WordPress site?

[ad_1]

Hi, I’m trying to learn WordPress and starting to experiment with CSS and JS. I have made a number a heading and would like to apply a ‘counting up’ effect.

Heading: 3,105,317+Count Up To: 3,201,465+

I would now like this to have a counting up effect. I came across [https://inorganik.github.io/countUp.js/]) and created this code using their tool:

<script src=”assets/plugins/global/plugins.bundle.js”></script>
const options = {
  startVal: 3105317,
  duration: 360,
};
let demo = new CountUp(‘counter’, 3201465, options);
if (!demo.error) {
  demo.start();
} else {
  console.error(demo.error);
}

I have added the CSS class of ‘counter’ to the heading. But now I’m not sure how do I actually apply this JS to the class? I’ve installed a plugin that will let me use custom JS but if someone could help I’d be very grateful!

[ad_2]
1 Comment
  1. I don’t know the answer to your question, but FWIW, the free Kadence Blocks plugin has a count up block.

    I use their free theme and free blocks, they work very well for me.

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer