/    Sign up×
Community /Pin to ProfileBookmark

code doesn’t work on Firefox 0.8, please help

Hello I have the following element in my site:

[code]
<span id=”elem”>Hello</span>
[/code]

I added the following JavaScript code that should modify the text in the span, but it doesn’t work in Firefox 0.8
It does work in Firefox 1.0

[code]
var obj = document.getElementById(‘elem’);
var nodes = obj.childNodes[0];
nodes.nodeValue = ‘test’;
[/code]

Does anyone know what the problem is?

I would also appreciate a URL to some knowledge base where I can read more about the DOM of Firefox (0.8 + 1.0)

regards

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@FangJan 12.2005 — var obj = document.getElementById('elem');
obj.firstChild.data='test';

Your code works in FF 0.7, maybe just a glitch in FF 0.8. I don't have FF 0.8 to test the problem.

EDIT FF 0.8 works correctly, [i]nodeValue[/i] is read only! http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/core.html#ID-F68D080

[URL=http://www.mozilla.org/docs/dom/domref/]Gecko DOM Reference[/URL]
Copy linkTweet thisAlerts:
@KorJan 13.2005 — var obj = document.getElementById('elem');

while(obj.hasChildNodes()){

obj.removeChild(obj.childNodes[0])

}

obj.appendChild(document.createTextNode('test'))
×

Success!

Help @jasongr spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.5,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...