Tagged: accordeon
-
AuthorPosts
-
May 20, 2021 at 3:11 pm #1301399
Hi,
I found this code to expand multiple accordeons at once on pageload and copied in QUICK CSS.
Works great, but affects now all accordeons on all pages, but I waant this to happen on just one page.js_active .toggle_wrap {
display: block;
position: static;
visibility: visible;
left: 0;
width: auto;
z-index: 1;
}is there a solution for jus6 a specific page?
Thank you very much!
Best,
TomMay 20, 2021 at 5:04 pm #1301451Hey thomaszechmhx,
Please provide a link to the site/page in question so we can look into this further.
Best regards,
Jordan ShannonMay 21, 2021 at 10:11 am #1301574This reply has been marked as private.May 23, 2021 at 11:43 pm #1301863Hi,
Thank you for your patience and the link to your page.
For your first question on how to get the CSS to only work on the one page, you would add the page ID to the CSS like this:.js_active .page-id-2575 .toggle_wrap { display: block; position: static; visibility: visible; left: 0; width: auto; z-index: 1; }
Each page has a unique page ID, now the reason you can not close the toggles is because the CSS has been set and clicking the toggles doesn’t change the state and the only way around this is by removing the CSS and writing a jQuery script to replace it.
I wrote this and it works when I inject it via the browser and it should work when it’s added to your functions.phpfunction custom_script() { ?> <script> (function($){ $(document).ready(function(){ $('#top.page-id-2575 .togglecontainer.enable_toggles').each(function() { $(this).find( '.toggle_wrap' ).css({'display':'block','visibility':'visible','position':'static','left':'0','width':'auto','z-index':'1'}); }); }); })(jQuery); </script> <?php } add_action('wp_footer', 'custom_script');
But in your theme options you have the “Load jQuery in your footer” option set so this will not work on your site because jQuery has to be loaded before the script for the script to work. I assume that you are trying to set your site to run the fastest so you will need to decide if giving up page load is worth closing the toggles, and if any of your visitors are ever going to try to close your toggles?
But at least you know the answer now.Best regards,
MikeMay 25, 2021 at 5:30 pm #1302264This reply has been marked as private.May 25, 2021 at 9:10 pm #1302294Hi,
Thanks we’ll await your response.
Best regards,
Jordan Shannon -
AuthorPosts
- You must be logged in to reply to this topic.