Hello everybody. I am very new to the JavaScript, and making only my first attempts to learn. As a small exercise I am trying to so something simple.
Pretty much I am trying to reposition button that i have on page load. What do i do wrong?
I would appreciate some help.
My code is bellow:
<style type="text/css">
.mybutton{
position:absolute;
}
JavaScript:
<script type="text/javascript">
window.onload=function(){
var mytestdiv = document.getElementById("testdiv");
var mytestbutton = document.getElementById("testdiv").childNodes()[0];
var y = mytestdiv.offsetWidth;
var x = mytestdiv.offsetHeight;
mytestbutton.style.right = x;
mytestbutton.style.top = y;
}
</script>
And my very simple html:
<body>
<div id="testdiv" style="width:500px;border:solid #000000">
<input type="submit" id="myButton" value="TestMe">
</div>
</body>
Edit: The error I am getting in furebug is:
mytestbutton.style is undefined