Home >Web Front-end >JS Tutorial >Example of making the scroll bars (slider) in two divs on the page move synchronously_jquery

Example of making the scroll bars (slider) in two divs on the page move synchronously_jquery

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-05-16 17:26:261564browse

Use JQuery to add the following code

Copy the code The code is as follows:

$('#sourceDiv') .scroll( function() {
$('#targetDiv').scrollTop($(this).scrollTop());
$('#targetDiv').scrollLeft($(this).scrollLeft( ));
});
$('#targetDiv').scroll( function() {
$('#sourceDiv').scrollTop($(this).scrollTop());
$('#sourceDiv').scrollLeft($(this).scrollLeft());
});

Rendering:
Example of making the scroll bars (slider) in two divs on the page move synchronously_jquery
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn