function myFunction() { var x = document.getElementById("myLI").parentNode.offsetHeight; document.getElementById("demo").innerHTML = x; }