473,406 Members | 2,549 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Retrieve css style for element?

219 100+
Is it possible to retrieve css style's using javascript?

I have an element which I've setup to not display when the page loads using

Expand|Select|Wrap|Line Numbers
  1. display:none;
  2.  
I want to retrieve the display value for the element and then change it based on what it is. I've tested this, and when I call hideshow the first time, there's no value for style.

Here is my javascript:

Expand|Select|Wrap|Line Numbers
  1. function hideshow(which){
  2.     if (!document.getElementById)
  3.         return;
  4.     if (which.style.display==""){
  5.         which.style.display="none";
  6.         return;
  7.     }
  8.     if (which.style.display=="block")
  9.         which.style.display="none";
  10.     else
  11.         which.style.display="block";
  12. }
  13.  
Oct 18 '07 #1
2 1265
acoder
16,027 Expert Mod 8TB
Moved from Articles section.

I think you may be looking for getComputedStyle().
Oct 18 '07 #2
dmorand
219 100+
Moved from Articles section.

I think you may be looking for getComputedStyle().

I'm sorry I keep posting in Articles. I have to pay better attention I guess.
Oct 18 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Billy | last post by:
Hi, I was wondering how to retrieve the cordinates of a CSS layer with javascript. I set the layer cordinates as like this in the header: <style type="text/css"> ..classID { position:...
5
by: Jeremy | last post by:
Apologies if the terminology isn't quite right here... say we have the following code: <SELECT NAME="p1_val" class=list-element> If the class "list-element" isn't defined, is it possible...
21
by: Michael Bierman | last post by:
Please forgive the simplicy of this question. I have the following code which attempts to determine the color of some text and set other text to match that color. It works fine in Firefox, but does...
2
by: mjansen.merge.emed | last post by:
Is there a way to override inline within the <bodya style of an element but not do it with a style attribute on the element? I know CSS Inheritance works for some styles, but doesn't appear to...
8
by: JT | last post by:
Hi, I have done a fair amount of style editing inline in ASP. I'm now using VS 2005 with a standard web project (not Web Application Project). This is my first foray into CSS in a style sheet...
1
by: Armin Gajda | last post by:
Hi, I have the following problem: An input field get a border assigned by a style class (e.g. 2px solid red). When the field gets the focus, we set the border to green. element.style.border...
4
by: yawnmoth | last post by:
Say I wanted to make a link change colors when someone was hovering over it. Ordinarily, I could do that by doing something like... <style> a { color: whatever; } a:hover { color:whatever;
4
Frinavale
by: Frinavale | last post by:
Is there a method like document.getElementByID() which will retrieve an element from another DOM element? Rephrasing: Say I retrieve a Div element using the getElementID method, is there a method...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.