Expandable Section A Bit Glitchy

I am using some custom javascript to add an expandable section on my site, however every time the button is pressed the screen jumps to a specific position. Is there a way to make the section expand without the screen jumping to center the collapsible section on the screen? Here is the code I am using.

jQuery(document).ready(function($){
$(’#expandable’).slideToggle(0);
$(’#expandable-trigger-button’).click(function(){
$(’#expandable’).slideToggle( “slow” );

    });
});

Hi there,

Thanks for writing around! Try replacing your code with the following code:

jQuery(document).ready(function($){
    $('#expandable').slideToggle(0);
    $('#expandable-trigger-button').click(function(event){
		event.preventDefault();
    	$('#expandable').slideToggle( "slow" );
    });
});

If this doesn’t help then please provide the page URL so we can take a look.

Thanks!

1 Like

This worked perfectly! Thank you very much!

Glad it worked.

Cheers!

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.