CMS Development

karensantana
Member

Jquery script not working in Hubspot but working fine in other site and console.

SOLVE

Hello Community!

 

I'm trying to add a jQuery to the header of my page, but for reason is not running. Also i tried putting the code in the console and it runs properly.

 

I just want to remove the second error message appearing in Subscription module in Hubspot using jQuery.

 

Anyone knows the reason why it has this behavior?

 

Subs.PNG

1 Accepted solution
tjoyce
Solution
Recognized Expert | Elite Partner
Recognized Expert | Elite Partner

Jquery script not working in Hubspot but working fine in other site and console.

SOLVE

@karensantana - I'm willing to bet that, since forms are loaded dynamically with JS, your script is triggering way too early, before the form elements have rendered. That's why you can run the script in console and it works. Most likely you are running the script when you can visibly see the form or the elements of the form you are trying to remove. Try putting your script in an interval just to test if it gets executed after a few seconds

 

setInterval(function(){ 
// run your code here
 }, 1000);

If this answer helped, please, mark as solved 😄


tim@belch.io | forms.belch.io | Design your own Beautiful HubSpot Forms; No coding necessary.

View solution in original post

2 Replies 2
tjoyce
Solution
Recognized Expert | Elite Partner
Recognized Expert | Elite Partner

Jquery script not working in Hubspot but working fine in other site and console.

SOLVE

@karensantana - I'm willing to bet that, since forms are loaded dynamically with JS, your script is triggering way too early, before the form elements have rendered. That's why you can run the script in console and it works. Most likely you are running the script when you can visibly see the form or the elements of the form you are trying to remove. Try putting your script in an interval just to test if it gets executed after a few seconds

 

setInterval(function(){ 
// run your code here
 }, 1000);

If this answer helped, please, mark as solved 😄


tim@belch.io | forms.belch.io | Design your own Beautiful HubSpot Forms; No coding necessary.

karensantana
Member

Jquery script not working in Hubspot but working fine in other site and console.

SOLVE

Thank you so much for your quick response!

 

I thought that with $(document).ready was enough, it worked like a charm.

 

Thanks again!