I've posted my question on the dev-tech-javascript list, but maybe it's
a DOM question ;-)
I use a jQuery TreeView where I'd like to change backgroundColor for
some elements...
So, I've written this code :
function refreshStriping () {
var collect_ul, fils, petits_fils, i, j, k;
// On récupère la collection de tous les 'ul'
collect_ul = document.getElementsByTagName("ul");
for (i=0;i<collect_ul.length;i++) {
fils = collect_ul[i].childNodes;
for (j=0;j<fils.length;j++) {
if (fils[j].tagName == "li") {
petits_fils = fils[j].childNodes;
for (k=0;k<petits_fils.length;k++) {
if (petits_fils[k].tagName = "span") {
petits_fils[k].style.backgroundColor:yellow";
}
}
}
}
}
}
But I have this error :
- setting a property that has only a getter !
I don't understand why I can't...
Do you have any clue ?
Thanks a lot.
David.
> if (petits_fils[k].tagName = "span") {
> petits_fils[k].style.backgroundColor:yellow";
The proper syntax is
petits_fils[k].style.backgroundColor = "yellow";
--
Martin Honnen
http://JavaScript.FAQTs.com/
But I still have the error :
setting a property that has only a getter !
I don't understand why...
David.
Le Thu, 31 Jul 2008 15:28:22 +0200,
Martin Honnen <maho...@yahoo.de> a écrit :
Also:
if (petits_fils[k].tagName == "span") {
--
John P Baker
> Also:
>
> if (petits_fils[k].tagName == "span") {
Right, and doing tagName = "span" probably caused the error "setting a
property that has only a getter".
Thanks a lot.
David.
Le Thu, 31 Jul 2008 09:07:59 -0500,
cc...@bristol.ac.uk (JP. Baker) a écrit :