Monday, May 13, 2024
 Popular · Latest · Hot · Upcoming
74
rated 0 times [  81] [ 7]  / answers: 1 / hits: 26149  / 10 Years ago, wed, october 8, 2014, 12:00:00

I have two independent web elements, if I scroll the content of one element, I also want the 2nd element scroll at same time. Here is an example: https://stackedit.io



I did the following code, but it is not working:



element.find('.fullscreen-mk-content-textarea').on('scroll', function(e){
// first element will trigger this event, then manully trigger the
// the scroll of the 2nd element. It's my plan.
console.log(e); // works
element.find('.right-side').trigger('scroll'); // doesn't work...
});


What shall I do?


More From » jquery

 Answers
41

Try this jsFiddle.



$('.e1').scroll(function(e){
$('.e2').scrollTop(parseInt($('.e1').scrollTop()));
});

[#69199] Monday, October 6, 2014, 10 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
jackelyn

Total Points: 303
Total Questions: 103
Total Answers: 102

Location: Turks and Caicos Islands
Member since Sun, Mar 7, 2021
3 Years ago
;