Originally posted by Supersonicdarky
wtf, why doesnt it work when above divs?
Because the JS is excecuted when the parser gets to that node, at which point the DIVs don't exist, because the page hasn't loaded fully. Therefore when the JS is excecuted the DIVs can't be found, but when the script node is below the DIVs then they do exist.
You can have the JS above the divs by using onload like Nathen said.
Originally posted by Napbree
document.getElementById('a').innerHTML = "width='300px';";
The first one is right, the second one will set the contents of the a div to "width='300px';", and wont change the width
innerHTML basically lets you access and change all the html within the node.