Jquery "if" function

Hello! I am trying to set an if function for Jquery, but it is not working. I wanted to know if the editor supported if functions, as when I remove them the function works.


 const emailamount = $('.cms-email-counter').length;

 let postNumber = 1;

if (postNumber >= 2) {
	$('#back').on('click', function(){
		postNumber = postNumber-1;

if (postNumber <= emailamount) {
	$('#next').on('click', function() {
  	postNumber = postNumber+1;




Hi @Julieta_Newland,
Welcome to the forum. It would be helpful if you follow the guidelines for posting to this category. Sharing a link to a published page where you are running this code is really essential to debugging.

The designer supports running custom code and any JS just needs to be correct. You can debug code in your browser and that is the best place to start.

Hi Jeff!

Oh, yes. Here is the link to the page: Newsletter .

I’ve tried looking in the console for errors everything seems to be working fine.

Thank you!

Hi @webdev I wondered if you had a chance to look at the project, thanks!


Sorry no. If you want coding help you could always submit a freelance request or wait. I am booked to the gills right now.

No problem! Thank you!