jQuery – linked horizontal scroll of 2 elements

0.0/5
<?php
add_action('wp_head', function() { ?>
	<script>
                //replace selector1 and selector2 with your selectors
		$(document).ready(function() {
    		$('selector1').on('scroll', function () {
        		$('selector2').scrollLeft($(this).scrollLeft());
    		});
			$('selector2').on('scroll', function () {
        		$('selector1').scrollLeft($(this).scrollLeft());
    		});
		});
	</script>
<?php });

Comments and reviews

{{ reviewsTotal }} Review
{{ reviewsTotal }} Reviews
{{ options.labels.newReviewButton }}
{{ userData.canReview.message }}

Description

This snippet adds a script that links the horizontal scroll of 2 DOM elements, meaning that scrolling one of them also scrolls the other one.

Author

Tags

This snippet is untagged