CMS Development

karensantana
メンバー

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

解決

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件の承認済みベストアンサー
tjoyce
解決策
名誉エキスパート | Elite Partner
名誉エキスパート | Elite Partner

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

解決

@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.

元の投稿で解決策を見る

2件の返信
tjoyce
解決策
名誉エキスパート | Elite Partner
名誉エキスパート | Elite Partner

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

解決

@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
メンバー

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

解決

Thank you so much for your quick response!

 

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

 

Thanks again!