jQuery variables aren't declaring

Hello fellow Webflowers!

I am working on a customized flow chart with a bit of logic for a client where they answer a series of questions that then show different screens based on their answers.

This uses jQuery to select various elements, update attributes that point to different links, etc.

I’m running into an issue where none of the variables I declare at the beginning of the code are being defined, which messes with functionality. But if I declare them in the console, everything works great.

I thought this could be because the variables are being declared before the page loads, so I wrapped it all within a $(document).ready( function() {}) code.

Can anyone help me figure out why this isn’t working? Preview link is below.


Here is my site Read-Only: LINK
(how to share your site Read-Only link)

Please share a published URL where your code can be inspected in a browser console.

1 Like

This won’t do anything if the issue is that the JQuery library hasn’t loaded yet.

My favourite thing to do in this case is to add an event listener:

document.addEventListener(“DOMContentLoaded”, function(){

[CODE]

});

Another possibility is to use window.onload:

window.onload = function()

You have to be careful if it’s a CMS item. There will be conflicts if you use multiple instances of window.onload.

Thanks for the response! Here’s the URL: Design Thinking Decision Flow Chart

@Spinnemensch Still not working. What it’s boiling down to is for some reason I can’t create variables out of the slider navigation dots, which means I can’t ‘click’ them with jQuery. But if I do it in the console, it defines just fine. I can’t tell if I’m missing something simple or not.