getStyle z-index

103 katselukertaa
Siirry ensimmäiseen lukemattomaan viestiin

kstubs

lukematon,
12.8.2011 klo 12.36.1312.8.2011
vastaanottaja prototype-s...@googlegroups.com
When calling getStyle, do you call out the style by camel-case?  So:

myElement.getStyle('zIndex');

-or-

myElement.getStyle('z-index');

Also, if the style has not been defined, as in z-index for example, you can expect a null return type, but aren't there default values that might be returned?

Karl..

shubhojoy

lukematon,
12.8.2011 klo 21.01.4212.8.2011
vastaanottaja Prototype & script.aculo.us
You use the camel case to get the z-index like so:

myElementZ = $(myElement).getStyle(zIndex);

Also, sometimes it can be a pain to realize that myElementZ is not an
integer. So, a parseInt(myElementZ) should guarantee that it can be
used for further calculations.

Not sure why you want to obtain any default values. IMHO, default
values can be notorious because of different browsers so the best way
to do things would be to always put your own value to it if it's
absolutely necessary.

One thing I frequently do is use a statement to get the topmost layer
z-index in the following way:
topZ_current = $$("div").invoke("getStyle", "zIndex").max();

Again, parseInt is required if you need the value for calculations,
which is probably the reason you did get it. Add 1 to it and place
your new element on top of the topmost layer...

Hope this helps you.

kstubs

lukematon,
13.8.2011 klo 23.50.0313.8.2011
vastaanottaja prototype-s...@googlegroups.com
Thanks for the feedback.  I was just curious if different properties of an element have a default value or not.  I like the use of max().

Karl..
Vastaa kaikille
Vastaa kirjoittajalle
Välitä
0 uutta viestiä