jQuery TwentyTwenty Plugin
-
Hi,
I’m trying to integrate the TwentyTwenty Tool inside my WordPress site:
https://github.com/zurb/twentytwentyI’m trying to do so without using one of the existing plugins since they don’t allow to use all the options when calling the script.
To do so, I downloaded the ‘twentytwenty-master.zip’ file, added the appropriate js and css files inside my child theme directories and added the lines below inside the ‘functions.php’ file:
function twenty_twenty_plugin() { wp_register_script( 'twenty_twenty_comparison_slider', get_stylesheet_directory_uri() . '/js/jquery.event.move.js', array('jquery'), '20171224', true ); wp_register_script( 'twenty_twenty_comparison_slider', get_stylesheet_directory_uri() . '/js/jquery.twentytwenty.js', array('jquery'), '20171224', true ); wp_enqueue_script( 'twenty_twenty_comparison_slider' ); wp_register_style( 'twenty-twenty-css', get_stylesheet_directory_uri() . '/css/twentytwenty.css', array(), '20171224', 'all' ); wp_enqueue_style( 'twenty-twenty-css' ); } add_action( 'wp_enqueue_scripts', 'twenty_twenty_plugin' );Everything seem to be loading perfectly fine since no issue is appearing in my navigator’s development tools and I see the different js and css files appearing inside the html source of the page.
But when I try calling the script inside the page using the code below:
<div class="twentytwenty-container"> <img src="image1.jpg" /> <img src="image2.jpg" /> <script type="text/javascript"> $(function(){ $(".twentytwenty-container").twentytwenty({ default_offset_pct: 0.7, // How much of the before image is visible when the page loads orientation: 'vertical', // Orientation of the before and after images ('horizontal' or 'vertical') before_label: 'January 2017', // Set a custom before label after_label: 'March 2017', // Set a custom after label no_overlay: true, //Do not show the overlay with before and after move_slider_on_hover: true, // Move slider on mouse hover? move_with_handle_only: true, // Allow a user to swipe anywhere on the image to control slider movement. click_to_move: false // Allow a user to click (or tap) anywhere on the image to move the slider to that location. }); }); </script> </div>I get this error :
TypeError: $ is not a functionThe error is referring to this line:
$(function(){I guess I’m not making the proper call.
Can somebody help me with this issue please?
Thank you very much.Best regards,
Stephane.
The topic ‘jQuery TwentyTwenty Plugin’ is closed to new replies.