/    Sign up×
Community /Pin to ProfileBookmark

DOM… Can you change the node Type of an element?

I know you can change the node value of an element in a document
but can you change the node value? if so how?

to post a comment
JavaScript

4 Comments(s)

Copy linkTweet thisAlerts:
@ZeroKilledOct 22.2008 — you are confusing me, you want to change the nodeValue or the nodeType? however, you can't assign a value to nodeType property because it is readonly. but you can replace the node with method replaceChild(node to replace with, which node to replace);
Copy linkTweet thisAlerts:
@maitopoikaauthorOct 22.2008 — Sorry i made a typo in there.

What I meant to say is I know it is possible to change the nodes VALUE


What I want to know is, is it also possible to change the nodes TYPE...

I don't think it is cause like you said it is read only but i just want to make sure.

Hope that is clearer now.
Copy linkTweet thisAlerts:
@KorOct 22.2008 — Only textNodes and attributeNodes have nodeValue, not all the nodes.

nodeType is a readonly property, it can not be changed. It makes no sense, anyway, to change the type of a node. What[I] in fact[/I] is your final aim? Why do you need that?
Copy linkTweet thisAlerts:
@maitopoikaauthorOct 22.2008 — It was a question in my Web Programming course at the University. (not a test)

It asked how you chang the nodeType if possible.

I figured it was a trick question in that you cannot change it but i wanted

to make sure.

So thank you all

I do appreciate it!
×

Success!

Help @maitopoika 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 6.16,
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: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

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