Log in

View Full Version : eliminating the id value of a variable.



Falkon303
03-26-2009, 05:17 AM
Ok, so let's say I have an array of 3 id values of li elements.

<ul id="main">
<li id="one"></li>
<li id="two"></li>
<li id="three"></li>
</ul>

No, you can get the array of these three a few different ways, but my question is, how do I eliminate the id value of one? What I have experienced when I set document.getElementById("two").id = '', is that in the lookup of the array of ids, this occurs - "one,,three" - which leave an annoying two comma problem. Any input on this?

- Ben

codeexploiter
03-26-2009, 07:29 AM
Try


document.getElementById("two").removeAttribute("id");

Falkon303
03-27-2009, 03:55 AM
Try


document.getElementById("two").removeAttribute("id");

Awesome. Thank you much. :)