How can i get the position from div top from the last elment in a scrollable div with jQuery? I have tried this but it doesnt work:
JavaScript
x
3
1
let bES = $(id).children().last().scrollTop()
2
console.log(bES)
3
Advertisement
Answer
You can use the .position()
method to read its top
property :
JavaScript
1
2
1
let bES = $('#content').children().last().position().top
2
console.log(bES)
JavaScript
1
8
1
div {
2
height: 60px;
3
overflow: scroll;
4
}
5
6
input {
7
display: block;
8
}
JavaScript
1
6
1
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
2
<div id="content">
3
<input value="123">
4
<input value="456">
5
<input value="789">
6
</div>