简体   繁体   English

如何在不使用 jquery 的情况下在 javascript 中使用滚动?

[英]How to use scroll in javascript without using jquery?

How to add scroll in JavaScript without using jquery?如何在不使用 jquery 的情况下在 JavaScript 中添加滚动? I just want to add scroll effect on a div without using jquery to make the code efficient.我只想在 div 上添加滚动效果而不使用 jquery 来使代码高效。

这是你的答案

document.queryselector("#btn").addEventListener("onscroll", displayDiv);

I searched and found another way to call it object.onscroll = function(){myScript};我搜索并找到了另一种调用它的方法object.onscroll = function(){myScript}; and it also worked它也有效

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM