i'm using this
div.left = parseInt(div.left)-100;
in a script
so change position of a div
so why can't i use this
div.z-index = parseInt(div.z-index)-100;
to change it's z-index
any help appriciated
Phil
| SitePoint Sponsor |
i'm using this
div.left = parseInt(div.left)-100;
in a script
so change position of a div
so why can't i use this
div.z-index = parseInt(div.z-index)-100;
to change it's z-index
any help appriciated
Phil





That should be zIndex, because div.z-index would treat the "-" as the subtraction operator and try to subtract a variable named "index" from div.z
ck :: bringing chris to the masses.
You should also be using [divID].style.left and [divID].style.zIndex to call the properties rather than directly calling left and z-index.
cheers to first reply - didn't think of that, but i thought you had to use z-index cos that was it's name, so zIndex is cool yes.
And second reply i have already put the divID into a variable so i am assuming that what you said is unnecessary - but thank none the less.
You should be doing something like this:
Code:var theDiv = document.getElementById("blah") var myLeft = theDiv.style.left; var myZ = theDiv.style.zIndex;HTML Code:<div id="blah"></div>
You are gonna have to excuse my stupidity - i've changed it to what you said, but now it won't even change the y pos
http://www.philspeakman.com/test/divZ.htm
i get the theory but am not to practised in dhtml - hence me wanting to learn, if you can shed any more light i would appriciate it, Phil
Bookmarks