Home › Forums › Support › Adding CSS -JS animation on click This topic has 4 replies, 2 voices, and was last updated 2 years, 10 months ago by David. Viewing 5 posts - 1 through 5 (of 5 total) Author Posts May 4, 2021 at 2:29 am #1763273 Alessandro Hello, i’m trying to integrate this code:https://codepen.io/thetallweeks/pen/boinE here: https://www.autozitra.it/chi-siamo-vendita/ I put the css code in the style.css of the child-theme. Then the html code into the page just before the footer.https://www.autozitra.it/chi-siamo-vendita/ : you will see a square and a button “click me”. Then the Js code in an element hook (wp_head) inside tag <script> </script>, execute php checked on. it doesn’t work… where am i wrong? Thank you very much… May 4, 2021 at 4:42 am #1763432 DavidStaff Customer Support Hi there, 1. so the JS you have is this: $("#button").click(function() { $('.transform').toggleClass('transform-active'); }); But WordPress doesn’t accept the $ variable for jquery it has to be predefined. Change the code to: jQuery("#button").click(function() { jQuery('.transform').toggleClass('transform-active'); }); 2. That code should be executed after the Button is loaded. Use the wp_footer hook instead. May 4, 2021 at 6:24 am #1763580 Alessandro Hi David, thank you very much, it works perfectly…i love Generatepress and its team! May 4, 2021 at 6:26 am #1763586 Alessandro resolved May 4, 2021 at 6:59 am #1763933 DavidStaff Customer Support Glad to be of help! Author Posts Viewing 5 posts - 1 through 5 (of 5 total) You must be logged in to reply to this topic. Log In Username: Password: Keep me signed in Log In