Help with this html/javascript code?

  • Thread starter Thread starter Human
  • Start date Start date
H

Human

Guest
<html>
<head>
<script>
function mlay() {
alert("hi");
document.getElementByID(layer1).style.color="green";
}
</script></head>
<body>
<div id=layer1 style="position:absolute; top:20; left:300;">Hi</div><button onClick="mlay()">h</button></body></html>


I want it to move the layer 600 px right
 
add some spaces so yahoo doesn't skrew up the code.

put quotation marks around layer1 in your script.
 
add some spaces so yahoo doesn't skrew up the code.

put quotation marks around layer1 in your script.
 
do you want to move it when the button is clicked like such:
<html>
<head>

<script type="text/javascript">
function mlay() {

document.getElementById("layer1").style.left="600px";
}
</script>

</head>
<body>
<div id="layer1" style="position: absolute; top: 20; left: 300px; ">
Hi
</div>
<button onclick="mlay()">
h</button></body></html>


the line should read:
document DOT
getElementById("layer1")
DOT
style
DOT
left="600px";
 
Back
Top