Javascript examples for CSS Style Property:top
Return the top position of a <div> element:
<!DOCTYPE html> <html> <body> <div id="myDiv" style="position:absolute;top:75px;">This is a div.</div> <button type="button" onclick="myFunction()">Return top position of div</button> <script> function myFunction() {/* w w w. j a v a2s .co m*/ console.log(document.getElementById("myDiv").style.top); } </script> </body> </html>