Reputation: 328
I'm trying to modify some CSS properties in a given element, this way:
var rsc_menu = document.getElementById("rsc_menu");
rsc_menu.style.top = 303;
rsc_menu.style.height = 29;
Unfortunately, after code execution the element still stays in its original position and preserves its original size.
I've noticed that alert(rsc_menu.style.top)
and alert(rsc_menu.style.height)
both show an empty box.
The element is declared like this:
<div class="resources_menu" id="rsc_menu">
As you can see, it takes all of its styling parameters from a foreign stylesheet; I defined no style
tags for it. May that be the problem? Is there any way to accomplish the task without having to change the <div>
tag?
Upvotes: 1
Views: 189
Reputation: 21367
You have to pass it:
So your code would be looking like this:
var rsc_menu = document.getElementById("rsc_menu");
rsc_menu.style.top = "303px";
rsc_menu.style.height = "29px";
Upvotes: 3