2023当HTML元素的滚动条被滚动时执行脚本?

 所属分类:web前端开发

 浏览:87次-  评论: 0次-  更新时间:2023-09-05
描述:更多教程资料进入php教程获得。 示例<!DOCTYPE html> <html> <head> <style> #myid { ...
更多教程资料进入php教程获得。

当HTML元素的滚动条被滚动时执行脚本?

示例

<!DOCTYPE html>
<html>
   <head>
      <style>
         #myid {
            width   : 250px;
            height  : 80px;
            border  : 2px solid blue;
            overflow: scroll;
         }
      </style>
   </head>
   <body>
      <p>Scroll the box.</p>
      <div id = "myid" onscroll = "display()">This is demo text. This is demo text. This is demo text. This is demo text. This is demo text. This is demo text.
      <br><br></div>
      <script>
         function display() {
            document.getElementById("myid").style.color = "blue";
         }
      </script>
   </body>
</html>

积分说明:注册即送10金币,每日签到可获得更多金币,成为VIP会员可免金币下载! 充值积分充值会员更多说明»

讨论这个素材(0)回答他人问题或分享使用心得奖励金币

〒_〒 居然一个评论都没有……

表情  文明上网,理性发言!