Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[Error] backgroundColor : setting a property that has only a getter !

6 views
Skip to first unread message

David BERCOT

unread,
Jul 31, 2008, 8:34:28 AM7/31/08
to dev-te...@lists.mozilla.org
Hello,

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.

Martin Honnen

unread,
Jul 31, 2008, 9:28:22 AM7/31/08
to
David BERCOT wrote:

> 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/

David BERCOT

unread,
Jul 31, 2008, 9:41:59 AM7/31/08
to dev-te...@lists.mozilla.org, Martin...@gmx.de
Sorry !!! I've put on the ml an old version !!!
I have in my code, the "proper" version ;-)

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 :

JP. Baker

unread,
Jul 31, 2008, 10:07:59 AM7/31/08
to
In article <mOGdnQCIq4xlIAzV...@mozilla.org>,

Martin Honnen <Martin...@gmx.de> wrote:
>David BERCOT wrote:
>
>> if (petits_fils[k].tagName = "span") {
>> petits_fils[k].style.backgroundColor:yellow";
>
>The proper syntax is
> petits_fils[k].style.backgroundColor = "yellow";

Also:

if (petits_fils[k].tagName == "span") {

--
John P Baker

Martin Honnen

unread,
Jul 31, 2008, 10:29:12 AM7/31/08
to
JP. Baker wrote:

> Also:
>
> if (petits_fils[k].tagName == "span") {

Right, and doing tagName = "span" probably caused the error "setting a
property that has only a getter".

David BERCOT

unread,
Jul 31, 2008, 10:41:43 AM7/31/08
to dev-te...@lists.mozilla.org
YES !!! What a stupid error !!!

Thanks a lot.

David.

Le Thu, 31 Jul 2008 09:07:59 -0500,
cc...@bristol.ac.uk (JP. Baker) a écrit :

0 new messages