Hi keesiemeijer, what was working on the test page does not work in the final page any more. I have done and re-done all steps several times, but it wouldn’t toggle.
Any idea what I should check ? I’m with my back to the wall.
https://current01.uptoconcept.com/toggle-test# (access with: admin xxxyyy)
This is the code I use :
My toggle.js:
jQuery(document).ready(function(){
//Hide (Collapse) the toggle containers on load
jQuery(“.toggle_container”).hide();
//Switch the “Open” and “Close” state per click then slide up/down (depending on open/close state)
jQuery(“h2.trigger”).click(function(){
jQuery(this).toggleClass(“active”).next().slideToggle(“slow”);
return false; //Prevent the browser jump to the link anchor
});
});
My function.php insert:
/* fh start : jQuery Toggle */
function my_scripts_method() {
// register your script location, dependencies and version
wp_register_script(‘toggle_script’,
get_template_directory_uri() . ‘/js/toggle.js’,
array(‘jquery’),
‘1.0’ );
// enqueue the script
wp_enqueue_script(‘toggle_script’);
}
add_action(‘wp_enqueue_scripts’, ‘my_scripts_method’);
/* fh end : jQuery Toggle */
My HTML:
My test in WordPress:
<h2 class=”trigger”>Toggle Header</h2>
<div class=”toggle_container”>
<div class=”block”>
<h3>Content Header</h3>
Content Content Content lalala
</div>
</div>
My CSS:
h2.trigger a {
color: #6CF;
display: block;
text-decoration: none;
}
h2.trigger a {
display: block;
text-decoration: none;
}