Uncaught TypeError: Cannot read property 'color' of undefined
Greetings,
I'm fairly new to jquery and have encountered the following problem. I'm trying to pass the id of a div into a function, (see code below), and get the "Uncaught TypeError: Cannot read property 'color' of undefined". I've simplified the code to make it more readable. Can someone tell me what I'm doing wrong? Thanks for reading this and thanks in advance for taking the time to respond.
<div id="div1" style="color:red">some text </div>
<div id="div2" style="color:blue">some text </div>
<div id="div3" style="color:green">some text </div>
<div id="div4" style="color:yellow">some text </div>
function InitializeTextEdit(pID) {
$fgColor=$("#div2")[0].style.color; //hard coded works fine
$bgColor=$(pID)[0].style.color; //here's where I get the error
}
//------------------------------------------ div2 Clicked
$("#div2").click(function(){
$(".hideable").hide();
$fn="#div2";
InitializeTextEdit($fn);
});