Adding Commas to Counters

this worked perfectly thanks Nabeel

Have a great day

Glad we could help.

Cheers!

Hi again,

I’ve tried using the latest code on one of my other sites and its not working. I added it into customizer. Could you please take a look for me? Thank you

Hi @Stigan .

Thanks for writing back! I went ahead and made some adjustments, I increased the timeout value and it seems to be working fine now. Please clear your browser’s cache and reload the site.

Cheers!

Thank you!

You are always welcome.

Cheers.

I tried every solution here and none work. Is it different for the Pro version?

Hi @Emperor,

Thank you for reaching out to us. I checked your page that has the counter and it needs a different approach since your front page doesn’t need scrolling to get to the counter element. It’s visible on the page load so you can try this code instead:

jQuery(document).ready(function() {
  setTimeout(function() {
			jQuery('.x-counter').each(function(){
				var theNumber =  jQuery(this).find(".x-counter-number").text();
				theNumber = theNumber.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
				jQuery(this).find(".x-counter-number").text(theNumber)
			});
      }, 500);
});

Don’t forget to clear all caches including your browser’s cache after adding the code. Let us know how this goes!

Hi

I’ve tried all of the coding above on my site, but none seem to work in adding a comma into my counter.

Is someone able to have a look at it?

This is one of my pages that has the counter - http://35.201.4.103/health/

Hi Kelvin,

Thanks for reaching out.

The reason why the code is not working on your end because the CSS selector you use is ".number" it should be ".x-counter-number" as given by my colleague. Please update your code and it will be working.

Your CSS selector in your code here:

should be match on the pre-define CSS here:

Please note that custom development is outside the scope of our support. Issues that might arise from the use of custom code and further enhancements should be directed to a third party developer.

Hope that helps.

Thank you.

Hi @cramaton,

Thanks for that, I’ve updated the code and, made sure the column and counter are being targeted correctly, it still is not working

Hi Kelvin,

I suggest that you create a new ticket to assist you better, check it here on how to create a new one:
Creating a new ticket

And on the new ticket, please give us the following information in a Secure Note.

  • WordPress Login URL
  • Admin level username and password

You can find the Secure Note button at the bottom of your posts.

Thank you.