etsted Posted May 26, 2014 Share Posted May 26, 2014 (edited) I know you can use javascript to hide elements, as a "delete option", but is that really the only way, or the most effecient? Edited May 26, 2014 by etsted Link to comment Share on other sites More sharing options...
dsonesuk Posted May 26, 2014 Share Posted May 26, 2014 you have to select parent to remove target child element for crappy IE, otherwise you could just use remove() var parentElement = document.getElementById("nav").parentNode; var childToRemove = document.getElementById("nav"); parentElement.removeChild(childToRemove); Link to comment Share on other sites More sharing options...
Ingolme Posted May 27, 2014 Share Posted May 27, 2014 I'm not aware of a remove() method, it's not part of the DOM specification. removeChild() is the proper way to remove an element from the tree. Link to comment Share on other sites More sharing options...
dsonesuk Posted May 27, 2014 Share Posted May 27, 2014 https://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#interface-element Link to comment Share on other sites More sharing options...
Ingolme Posted May 27, 2014 Share Posted May 27, 2014 Oh, yes. It is just a working draft and has warnings. W3C says: Publication as a Working Draft does not imply endorsement by the W3C Membership. This is a draft document and may be updated, replaced or obsoleted by other documents at any time. It is inappropriate to cite this document as other than work in progress. MDN says: This is an experimental technologyBecause this technology's specification has not stabilized, check the compatibility table for the proper prefixes to use in various browsers. Also note that the syntax and behavior of an experimental technology is subject to change in future versions of browsers as the spec changes. Link to comment Share on other sites More sharing options...
dsonesuk Posted May 27, 2014 Share Posted May 27, 2014 It should have introduced a long time ago, seems stupid method to use the element you wish to remove to refer target its parent, after which you target the element itself AGAIN by its parent. Windows Vista programmers great idea i presume. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now