Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> การเขียนโปรแกรม >> JavaScript

วิธีตั้งค่าตำแหน่งด้านล่างขององค์ประกอบที่จัดตำแหน่งด้วย JavaScript


หากต้องการตั้งค่าตำแหน่งด้านล่างขององค์ประกอบที่จัดตำแหน่งด้วย JavaScript ให้ใช้คุณสมบัติ bottom

ตัวอย่าง

คุณสามารถลองรันโค้ดต่อไปนี้เพื่อเรียนรู้วิธีตั้งค่าตำแหน่งด้านล่าง −

<!DOCTYPE html> <html>    <head>       <style>          #newBtn {             position: absolute;          }       </style>    </head>    <body>       <button type="button" id="newBtn" type="button" onclick="display()">Set Bottom Position</button>       <script>          function display() {             document.getElementById("newBtn").style.bottom = "400px";           }       </script>    </body> </html>