How to set the bottom position of a positioned element with JavaScript?

JavascriptWeb DevelopmentFront End Scripts

To set the bottom position of a positioned element with JavaScript, use the bottom property.

Example

You can try to run the following code to learn how to set the bottom position −

Live Demo

<!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>
raja
Published on 27-Feb-2018 10:21:23
Advertisements