Let's say you have a tooltip with a lot of content so you need to have it scrollable. Of course you can't move your mouse over to scroll the tooltip since the tooltip will get hidden when you navigate away with your coursor.
<!-- Let's assume this is my tooltip and -->
<div id="scrollableTooltip">
<p>foo bar foo bar foo bar foo bar foo bar foo bar
foo bar foo bar foo bar foo bar foo bar foo bar
foo bar foo bar foo bar... ∞ </p>
</div>
<div id="triggerDiv">
<!-- When I hover and scroll here, I want to scroll my tooltip -->
<p>Scroll inside me to trigger scroll in div above...</p>
</div>
I have tried the following in order to target the mousewheel DOMMouseScroll
event and then using jQuery to try to trigger a scroll in my tooltip div - but without any success (Please see my JSFiddle):
$('#triggerDiv')
.on('mousewheel DOMMouseScroll', function (e){
console.log("Scroll was triggered...", e);
// 1.
$('#scrollableTooltip').scroll();
// 2.
// $('#scrollableTooltip').trigger('scroll');
});
CSS
#scrollableTooltip {
border: 1px solid red;
height: 100px;
overflow-y: scroll;
margin-bottom: 30px;
}
#triggerDiv {
border: 1px solid red;
height: 200px;
}