By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,702 Members | 1,760 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,702 IT Pros & Developers. It's quick & easy.

why does getting style.color or an element return nothing?

P: n/a
<style type="text/css">

<script language="Javascript" defer="defer">

function test(){


function test2(){
x = document.getElementById('cssdata');

<span id="cssdata">  hello </span>
<div class="test" onclick="test()">testing 2
returns two empty alerts in IE version 6.0 xpsp2

I have also tried without a defer attribute of course.

cssRules is undefined.

Aug 24 '05 #1
Share this Question
Share on Google+
1 Reply

P: n/a

pantagruel wrote:

<style type="text/css">
</style> function test2(){
x = document.getElementById('cssdata');
return; <span id="cssdata">  hello </span> represents the inline style of an element set in the HTML
style attribute or with script thus if you have
<span style="color:blue;">
then will give you a color value (might be 'blue'
but a browser also give you the color as an rgb triplet) but in your
example you get the empty string as the inline style is empty.

If you want the computed CSS value then you need a different scripting
approach using getComputedStyle for Mozilla and Opera and currentStyle
for IE.

Martin Honnen
Aug 24 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.