शीर्ष स्थान निर्धारित करने के लिए, शीर्ष . का उपयोग करें जावास्क्रिप्ट में संपत्ति। आप जावास्क्रिप्ट के साथ एक div की शीर्ष स्थिति निर्धारित करने के लिए निम्न कोड चलाने का प्रयास कर सकते हैं -
उदाहरण
<!DOCTYPE html>
<html>
<head>
<style>
#myID {
position: absolute;
}
</style>
</head>
<body>
<button onclick="display()">Set Top Position</button>
<div id = "myID">
This is demo text! This is demo text!
</div>
<script>
function display() {
document.getElementById("myID").style.top = "100px";
}
</script>
</body>
</html>