How to use jquery

I’ve been trying to use jquery in Softr, but I can’t seem to get it to work.

My code works on jsFiddle, but when I copy it over, it doesn’t.

I’ve tried including the library but noticed that Softr already includes it. Either way, it doesn’t work.

Any ideas?

Hi @jclay12345 and welcome to the community!

It would be great if you can post the code that you are having trouble with, and please do if this tip doesn’t help.

But even without that, the most common reason that jQuery-related code doesn’t work in a Softr custom code block is that it’s running too soon. It’s a good practice to wrap your jQuery code in a block like this:

const wait = setInterval(function() {
  if (typeof $ === "function") {
    // do the rest of the work you need to do
}, 500);

Thank you so much! It worked!

1 Like