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