Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CSS Attributes and JavaScript Attributes 1

Status
Not open for further replies.

1DMF

Programmer
Jan 18, 2005
8,795
GB
Not sure if I need the JS forum, but here goes...

I have an element which is display:none; using CSS.

However if i then display the style setting for the element with JavaScript it shows as ''

Even if the element is set to display:block; with CSS Javascript shows it as undefined.

So it seems the JS collection of info on the DOM is not changed / set by CSS, is this correct and how do you get round this problem?

Cheers,

1DMF

"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!
 
Thanks Feherke,

I thought as much, the way it was behaving seemed as though there were separate repositories for the attribute settings that the browser then applies.

The easiest way i got round this is via part of the onload JS , I set the default display for each element via JS , so then my 'Show/Hide' toggle functionality works properly.

Seems a bit silly having to set them again after already being set via CSS, but hey ho, just the way it is.



"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top