Forum Replies Created
-
AuthorPosts
-
Thanks Ismael, it’s ok now. here is the final code :
//------------------------------- // Toggle section //------------------------------- function toggle_on_click(){ ?> <script> jQuery(window).load(function(){ // Button onClick event jQuery(".toggle-button a").on("click", function() { // Add your button events here console.log("toggle section"); jQuery( "#toggle-section" ).animate({ opacity: 1, height: "toggle" }, 1500, function() { // Animation complete. }); console.log("Prevent default"); e.preventDefault(); }); }); </script> <?php } add_action('wp_footer', 'toggle_on_click'); function add_custom_href_remove(){ ?> <script> jQuery(window).load(function(){ jQuery('.toggle-button a').removeAttr('href'); }); </script> <?php } add_action('wp_footer', 'add_custom_href_remove');
where can i had this function ? for the moment i have this in functions.php:
//——————————-
// Toggle section
//——————————-function toggle_on_click(){
?>
<script>jQuery(window).load(function(){
// Button onClick event
jQuery(“.toggle-button a”).on(“click”, function() {
// Add your button events here
console.log(“toggle section”);
jQuery(“#toggle-section”).toggleClass(“hide-me”);
console.log(“Prevent default”);
e.preventDefault();
});
});
</script>
<?php
}
add_action(‘wp_footer’, ‘toggle_on_click’);function add_custom_href_remove(){
?>
<script>
jQuery(window).load(function(){
jQuery(‘.toggle-button a’).removeAttr(‘href’);
});
</script>
<?php
}
add_action(‘wp_footer’, ‘add_custom_href_remove’);jQuery(“.toggle-button a”).on(“click”, function(e) {
replaced by
jQuery(“.toggle-button a”).on(“click”, function() {
work nowIs there a way to animate the opening and closing of the section so that the transition is less ‘abrupt’?
- This reply was modified 4 years ago by Anna.
-
AuthorPosts