/    Sign up×
Community /Pin to ProfileBookmark

parent.mychild.removeChild(mychild)

can somebody explain to me again why this doesnt work please ?

mychild=document.getElementById(‘mychild’)
parent.mychild.removeChild(mychild)

to post a comment
JavaScript

4 Comments(s)

Copy linkTweet thisAlerts:
@DudeclesAug 22.2006 — because the remove function doesn't take children... use the PutUpForAdoption() or ThrowInADumpster() functions.
Copy linkTweet thisAlerts:
@gert_cuykensauthorAug 22.2006 — And why does this

div=document.getElementById('myparent')

div.removeChild(div.childNodes[0])

give me

[Exception... "Component returned failure code: 0x80004003 (NS_ERROR_INVALID_POINTER) [nsIDOMHTMLDivElement.removeChild]" nsresult: "0x80004003 (NS_ERROR_INVALID_POINTER)" location: "JS frame :: http://localhost/gert/db/js/server.js :: anonymous :: line 31" data: no]
Copy linkTweet thisAlerts:
@mrhooAug 23.2006 — parent.mychild is not an object:

(parent refers to a [B]window[/B],

the element with the id "mychild" is a child of it's parent node,

perhaps the "body", in the context of the [B]document [/B])

you need:

[B]mychild.parentNode[/B].removeChild(mychild);
Copy linkTweet thisAlerts:
@gert_cuykensauthorAug 23.2006 — http://www.w3schools.com/htmldom/dom_obj_window.asp

Window Object

The Window object represents the browser window. A Window object is created automatically with every instance of a <body> or <frame> tag.[/QUOTE]


I think parent.mychild is a object but for some reason i realy dont understand they make life complicated by saying you need a object node (some sort off non objective strange thing) to remove a object lol. So that brings us to the question what is a node and why cant they just stick to objects ? And if a node defines a object why cant a object defines itself ?
×

Success!

Help @gert_cuykens 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.4,
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,
)...