We have a div with fixed size with scroll auto, inside it we have another div bigger than the parent (wrapper) and inside it, more div elements(See example)
Is there a ready solution to find the div element's id in the position we scrolled to?
<div id="main">
<div id="content">
<div id="1" class="inner-content">1</div>
<div id="2" class="inner-content">2</div>
<div id="3" class="inner-content">3</div>
<div id="4" class="inner-content">4</div>
<div id="5" class="inner-content">5</div>
<div id="6" class="inner-content">6</div>
<div id="7" class="inner-content">7</div>
<div id="8" class="inner-content">8</div>
</div>
</div>
#main {
width: 700px;
height: 400px;
border: 1px solid black;
overflow: auto;
}
#content {
width: 10000px;
height: 10000px;
overflow: hidden;
}
.inner-content {
width: 900px;
height: 300px;
border: 1px solid black;
display: inline-block;
}
For example I scrolled right on div element with id 4, is it possible to return, with JavaScript or JQuery, the id of this element? After that I scrolled left on element with id 7 can I return this element's id?
Thx!