JavaScript Tutorial/Style/left
Change element left position
<html>
<head>
<style>
div { position:relative;
}
</style>
<title>Animating Text</title>
<SCRIPT LANGUAGE="JavaScript" type = "text/javascript">
var pos1 = 0;
function f() {
pos1 += 5;
if (pos1 > 640)
pos1 = 0;
document.getElementById("movetext").style.left = pos1;
window.setTimeout("f();",300);
}
</SCRIPT>
</head>
<body onLoad="f();">
<div id="movetext">
<b>inside a div</b>
</div>
</body>
</html>
div.style.left="200px";
<html>
<head>
<title>PrettyPretty</title>
<script type="text/javascript">
document.onclick=changeElement;
function changeElement() {
var div = document.getElementById("div1");
div.style.backgroundColor="#00f";
div.style.width="500px";
div.style.color="#fff";
div.style.height="200px";
div.style.paddingLeft="50px";
div.style.paddingTop="50px";
div.style.fontFamily="Verdana";
div.style.fontSize="2em";
div.style.border="3px dashed #ff0";
div.style.position="absolute";
div.style.left="200px";
div.style.top="100px";
div.style.textDecoration="underline";
}
</script>
</head>
<body>
<div id="div1">
This is a DIV element. Click me to see the change.
</div>
</body>
</html>