clientTop property is used to find the width between the top border and the element.
When calculating, top margin and padding are not added.
var elem = element.clientTop;
Example - Get clientTop of an element
- In the above example we have created a div (idDiv), and have specified border for the element.
- When the button is clicked, fun_name function is called.
- Using the clientTop property, width between the top border and the element is calculated and displayed (alert(elem.clientTop)).