...

View Full Version : append an id ?



Kor
12-17-2004, 02:26 PM
Does anyone knows how to append an id to a created element? (I've searched around, but found only a classic solution to use a method to give a class name, but I strongly need to append an id, not a class)

Willy Duitt
12-17-2004, 02:35 PM
setAttribute('id','ID HERE') ????

Kor
12-17-2004, 02:43 PM
Well hmm, I know that it works, yet I always thought that id is not an attribute (same as class)... Is setAttribute('id','blah') a W3C correct method?

Willy Duitt
12-17-2004, 03:35 PM
Well hmm, I know that it works, yet I always thought that id is not an attribute (same as class)... Is setAttribute('id','blah') a W3C correct method?

Why take my word for it when the answer is easily found over at W3C...
Try searching for: W3C setAttribute....

.....Willy

brothercake
12-17-2004, 05:43 PM
It is yeah, but not actually necessary in this case - a created element implictly has an ID attribute already, so you all have to do is go:


ele.id = 'whatever';

Maybe that implicit existence is why you were thinking of it as different? Class attributes are like this as well.

Kor
12-17-2004, 06:16 PM
a created element implictly has an ID attribute already

...yea... I should have thought about that...
Tx to all :thumbsup:



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum