Floating button on specific page

Hi I want to add a floating button on a specific page on my website.
I’ve tried this :

Custom > JavaScript in the Customizer:

jQuery(document).ready(function($) {
if( ! $(‘body’).hasClass(‘page-id-210’) ) {
$(‘Button Text’).appendTo(’.site’);
}
});

Custom > CSS

.site .floating-button {
position: fixed;
top: 10px;
left: 10px;
z-index: 10001;
}

But of course, it shows on every page. What do I have to change to set it to a specific page?

Hi @ProductionMD1986,

Little confuse of the custom CSS and JS. Base on my understanding of the code you shared, to float a button on a specific page, use this CSS below:

.page-id-210 .site .floating-button {
   position: fixed;
   top: 10px;
   left: 10px;
   z-index: 10001;
}

Hope it helps.

Let us know how it goes.

Thanks.

Perfect! It worked (with the proper page id of course).

Glad to hear it’s sorted.

Cheers!

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