Okay
  Public Ticket #3328250
Adding Javascript
Closed

Comments

  •  40
    ep started the conversation

    Hi, I have a question about adding JavaScript via Theme Options.

    If I have script like below, is there some format I have to follow when I paste it for it to work? Like <script> or jQuery or anything? (This is my first time to try using js). And does it matter if it goes in Header or Footer?

    Thank you!


    $('#fragrance').on('change', function(){
        $('body').addClass('class-1');
    });

  •  1,558
    Laborator replied

    Hi there,

    If you want to add jQuery then this is the method to add it:

    <script>
    jQuery( document ).ready( function( $ ) {
      $( '#fragrance' ).on( 'change', function() {
        $( 'body' ).addClass( 'class-1' );
      } );
    } );
    </script>
    

    Best regards,
    Laborator Team


      Documentation         Join Kalium Users Group

  •  40
    ep replied

    Fantastic, thanks so much!