freelancelote 24 Junior Poster in Training

Hi,
I'm starting playing with javascript and bounce to some problems.
The script tries to read the <p> background color that is set using stylesheet and set a global variable with this value for later use.
It seems that the variable does not instantiate (and btw. there is more than one <p> on my html document)
Here is the snippet:

window.onload= function(){
pSections = document.getElementsByTagName("p");
originalColor = pSections[0].style.backgroundColor;
alert("the original color was: " + originalColor);
}

Do you know why is this not working? Any help appreciated,
thanks

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.