Set top value in Javascript

Description

The following code shows how to set top value in Javascript.

Example


<!DOCTYPE html>
<html>
<body>
  <div id="div1">This is a DIV element. Click me to see the change.
  </div><!-- w  w w .  jav a2 s .c  o m-->
  <script type="text/javascript">
    var div = document.getElementById("div1");

    div.style.color = "#fff";
    div.style.fontFamily = "Verdana";
    div.style.fontSize = "2em";
    div.style.borderBottom = "3px dashed #ff0";
    div.style.position = "absolute";
    div.style.left = "20px";
    div.style.top = "10px";
  </script>
</body>
</html>

Click to view the demo





















Home »
  Javascript »
    Javascript Reference »




Array
Canvas Context
CSSStyleDeclaration
CSSStyleSheet
Date
Document
Event
Global
History
HTMLElement
Input Element
Location
Math
Number
String
Window