Back to top id in bricks

Hi,

I want to create a back to top button. Until now, I used #brx-header for this. But the problem is that if the sticky header is enabled, it won’t work anymore. So I wanted to ask what identifier is there in bricks that will direct the user to the top of the page?

2 method.

No.1: use js, add .backtotop class to the button. (code add on footer template page Header scripts)

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
  $(".backtotop").click(function(){
    $("html").scrollTop(0);
  });
});
</script>

No.2: add a div before headre use PHP,use code snippest, change the #brx-header to #backtotop

<?php
add_action('bricks_before_header', 'c_do_before_header_backtoptop');
function c_do_before_header_backtoptop(){
	echo '<div id="backtotop"></div>';
}
?>
1 Like