How to add Javascript events to the Carousel view

Add this to your site’s js to enable events such as adding Google Analytics tracking code to individual Carousel slides:

jQuery(document).on( 'jp_carousel.selectSlide', '.jp-carousel-wrap', function( event, slides ) {
	// This is just to show you what values get passed in.  Delete it before going to production.
	if ( window.console ) {
		console.log( this );
		console.log( event );
		console.log( slides );
		console.log( slides[0] );
	}
	// Do whatever extra stuff you want here.
} );

You can read more about it here.

Posted in Code snippets, Tips & Tricks | Tagged , , | Comments Off on How to add Javascript events to the Carousel view
  • Recent Comments

    Jakob Boman on Jetpack 4.6: Google Analytics…
    Jeremy on Jetpack 4.6: Google Analytics…
    Jeremy on Jetpack 4.6: Google Analytics…
    Girolamo Aloe on Jetpack 4.6: Google Analytics…
    eemskrant on Jetpack 4.6: Google Analytics…
  • Archives

  • Enter your email address to follow this blog and receive notifications of new posts by email.

  • Relied on by millions of WordPress professionals worldwide.

    Install Free   See Pricing

    Created by Automattic: bringing the power of WordPress.com to every WordPress site.