PDA

View Full Version : style.backgroundColor returning empty string



NewTechGuy
13 Nov 2009, 01:28 PM
echo "<div id='d1' onclick=\"alert(this.style.backgroundColor)\" width='100%'>content</div>";

This line of code is working but for some reason it is returning an empty string. I have set the css background color of the div in internal(not inline) css above the div. What am I missing here?

Thanks,
NewTechGuy

usedearplugs
15 Nov 2009, 01:57 PM
At first I thought you needed to use background-color, but I was wrong. If you use inline styles, your command will work, but it's not grabbing it from the stylesheet. I've had that problem before. Doing some more research.