【发布时间】:2019-06-30 22:59:24
【问题描述】:
我有两个独立的网页元素,如果我滚动一个元素的内容,我还希望第二个元素同时滚动。这是一个例子:https://stackedit.io
我做了以下代码,但它不起作用:
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...
});
我该怎么办?
【问题讨论】:
-
Romeo 的答案确实有效,只是不要忘记 ID 选择器使用哈希(#)而不是句号(。)希望这对像我这样的初学者有帮助,他们试图找出如何触发事件滚动。
标签: javascript jquery