In my webpage there is CTA href link but i dont want to redirect that link. I want to scroll to page section. So my question is that i used below code but does not working:
$(document).ready(function(){
$(“#cta_button_3852769_81fc24f7-1d1b-4cf0-aea6-b420d199a42b”).click(function(event){
event.preventDefault();
});
});
@suniltodkar - CTA’s load in dynamically so, you are probably executing that code before the button is available. You should attach the listener to the document or add an interval that checks for the existance of the CTA.
I answered a similar question here: https://community.hubspot.com/t5/Content-Design-Questions/CTA-does-not-take-anchor-for-rich-text/m-p/197884#M6944
$(document).on("click", '.hs_cos_wrapper_type_cta a', function(e) {
var thisE = $(this);
var linkto = thisE.attr('cta_dest_link');
if (linkto.indexOf('#') > -1) {
var hashid = linkto.split("#").pop();
$('html, body').animate({ scrollTop: $('#'+hashid).offset().top}, 1000);
e.preventDefault();
}
});
If this answer helped, please, mark as solved ![]()
tim@belch.io | forms.belch.io | Design your own Beautiful HubSpot Forms; No coding necessary.
Drop by and say Hi to me on slack.