简体   繁体   中英

mouse wheel scroll DIV element

If I have two DIV elements :

#my-div1 {
  position:absolute; /* relative or fixed  */
  z-index:20;
}
#my-div2 {
  position:absolute;
  z-index:10;
  height:500px;
  overflow:scroll;
}

Is it possible to scroll #my-div2 when mouse cursor is over #my-div1 , using javascript?

You could use .mouseover() in combination with a scrolling library to execute the scrolling javascript:

$('#my-div1').mouseover(function() {
  //use Scroll library
});

A good library is ScrollTo .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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