[Resolved] Adding CSS -JS animation on click

Home Forums Support [Resolved] Adding CSS -JS animation on click

Home Forums Support Adding CSS -JS animation on click

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #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…

    #1763432
    David
    Staff
    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.

    #1763580
    Alessandro

    Hi David,
    thank you very much, it works perfectly…i love Generatepress and its team!

    #1763586
    Alessandro

    resolved

    #1763933
    David
    Staff
    Customer Support

    Glad to be of help!

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.