I know you can change CSS values by using:
var doodhah = document.getElementById('name')
doodah.style.value = 'value'
But what do I do if I want to find out what the value of doodah.style.value already is?
hmm, that didn't work.
I also tried putting it into a function but that didn't work either. I'll paste the relevant code below. (For the time being I've put the values directly into the script but I changed the first element in the array to show what I'd like to do).
var homeInfo = document.getElementById('home');
var homeBgCol = homeInfo.style.backgroundColor;
bgCol = [homeBgCol];
bgCol = ['#aa7a00'];
bgCol = ['#dab372'];
bgCol = ['#bc8860'];
If I examine the js console in Firefox I get told:
Error: homeInfo has no properties.
Of course, it does have properties and the same code works fine elsewhere in the script. The relevant css is reproduced below:
I'm pretty dim when it comes to js, but I think you want background instead of backgroundcolor, and I think you need something after background to refer to the array.
backgroundColor is right because it works elsewhere in the script. I think background is for an image.
I didn't relate all of the code above but I've got a function calling the array elements later on in the script which actually sets the stuff. That works fine as well. The script works fine if I put the values directly into the array; it's only when I try to call the colours from the CSS that I run into problems. It's doesn't matter too much having the colours described in the script but I'd rather keep them in the CSS where they idealy belong.
I don't understand why the parser returns that error either because I have similar code elsewhere in the script that produces no such error.
You must login to reply