Forum Moderators: open

Message Too Old, No Replies

building stuff with the DOM

how i hate IE

         

natty

1:31 pm on May 12, 2006 (gmt 0)

10+ Year Member



Hi all,

having a bit of problems with IE again.. as per normal, anyone know where the developers live? i have something to send them - a brick ... grrrrrr

ok moan over..
but simply i am using
x=document.createElement("div");
x.setAttribute("class","classname");

and then appendchild etc to add them to the page.
which of course works a treat in FF, and does actually add the elements into the page in IE, but does it add the class details..? does it *%$!

and then i have a problem with trying to remove them from the page again with removeNode

ive added the elements in , and given them a holding div called .. question_1, question_2 etc..
so i do
document.getElementByID("question_1").removeNode(true);

using true to bin all the child nodes also.
but this refuses to work in FF or IE, so im lost there.
if i alert the doc.getElById("question_1") it has found a div.. hoorah
so why when i do x = doc.blahthing and then x.removeNode(true) does ti not work?!
i do like JS, but it isnt half a bugger when it doesnt play ball..

any help with this rant much appreciated as per..

cheers all

nat

jshanman

1:46 pm on May 12, 2006 (gmt 0)

10+ Year Member



.setAttribute is known to be buggy in IE (just search for "setattribute ie")

I've had much more success with

x.className = "whatever";

Not sure about the removeNode thing, but your post is hard to understand. Post the actual code so we can read it.

IIRC:
document.getElementByID("question_1").removeNode(true);
will remove all direct children of "question_1" and will set all those childrens children to be a child of "question_1". You can put is this way: The removeNode method just removes the specified element and makes its descendents children of their grandfather.

If that makes sense :)
- JS

natty

2:18 pm on May 12, 2006 (gmt 0)

10+ Year Member



hi there js,

thanks for the reply.

got the remove thing working, ended up with

x.parent.removeChild(x);
which seems to work reliably

ill try the simply x.className and see how i get on..
thanks again