inherit
Frozen in Time
1515
0
Nov 18, 2012 23:46:48 GMT -8
snap2000
29,317
October 2001
snap2000
|
Post by snap2000 on Jun 26, 2005 14:42:21 GMT -8
Ah okay, but let's say I have something like this: <span id="blah">Hello World</span> And I want to change it to "Goodbye World" without writing using innerHTML or removing the span element completely and creating a new one. How exactly could that be done? Using innerHTML: document.getElementById("blah").innerHTML="Goodbye World"; Using DOM you could add a text node that says goodbye world, but how would you remove the existing text, since it isn't in any sort of 'child' so you can't use removeChild() or replaceChild(). Would this work? var oldText=document.createTextNode("Hello"); var newText=document.creatTextNode("Goodbye"); document.getElementById("blah").replaceChild(oldText,newText);Actually, the text is still a child node. You can remove/replace it just like any other.
|
|
acoolie530
inherit
-148471
0
Nov 30, 2024 2:40:06 GMT -8
acoolie530
0
January 1970
GUEST
|
Post by acoolie530 on Jun 27, 2005 10:14:11 GMT -8
|
|
inherit
Proboards Legend
212
0
May 11, 2006 12:32:55 GMT -8
california
21,035
December 1999
california
|
Post by california on Jun 27, 2005 22:33:52 GMT -8
Ah okay, I was confusing childNodes with children. Apparently childNodes includes text and children refers only to HTML tags?
|
|
inherit
2671
0
May 14, 2013 14:40:03 GMT -8
Peter
🐺
10,615
February 2002
peter3
|
Post by Peter on Jun 28, 2005 1:16:32 GMT -8
Ah okay, I was confusing childNodes with children. Apparently childNodes includes text and children refers only to HTML tags? Yeah, children is a collection of all elements in the current element except for text nodes. So the best thing to use would be childNodes, as children is IE only.
|
|
inherit
Beware the ever changing head
33588
0
Nov 18, 2023 0:32:44 GMT -8
Ross
19,039
November 2004
elindir
|
Post by Ross on Jun 28, 2005 7:18:12 GMT -8
DOM is just too confusing for me All these parents and children all over the place. I think I would rather stick to the easy innerHTML for now
|
|
inherit
38464
0
Jun 8, 2007 12:03:04 GMT -8
[HkK Rly]
1,742
March 2005
maddenking2
|
Post by [HkK Rly] on Jun 28, 2005 13:29:00 GMT -8
DOM is just too confusing for me All these parents and children all over the place. I think I would rather stick to the easy innerHTML for now Same for me I don't have time to use this DUM stuff. innerHTML is much easier to use than DOM IMO.
|
|
inherit
22517
0
Apr 30, 2009 18:49:13 GMT -8
Bradley
Has a new webhost. :) Needs to transfer a lot of stuff. :-/
5,246
April 2004
ccworldwebmaster
|
Post by Bradley on Jun 28, 2005 14:16:37 GMT -8
Most of the time I'll do something like this:
var someChild = document.createElement("span"); someChild.innerHTML = "Weeeeeeeeeeee"; someChild.style.color = "#ff0000"; var someDiv = document.getElementsByTagName("div")[2]; someDiv.appendChild(someChild);
I just end up mixing in whatever is convenient.
|
|
inherit
EXOH
27575
0
Nov 12, 2007 22:40:30 GMT -8
J. Meeter
i do my crosswords in pen
8,249
July 2004
modernxxromance
|
Post by J. Meeter on Jun 28, 2005 19:30:09 GMT -8
DOM is just too confusing for me All these parents and children all over the place. I think I would rather stick to the easy innerHTML for now Same for me I don't have time to use this DUM stuff. innerHTML is much easier to use than DOM IMO. It may be easier, but it's wrong.
|
|