@scragarSep 06.2008 — #function removeElement(ele){ if(ele.parentNode && ele.nodeType){ ele.parentNode.removeChild(ele); return true; }else{ return false;// not an element or no parent :( }; };
@Declan1991Sep 06.2008 — #Probably because you are not passing a string<input type="button" value="Delete" onClick="removeElement([color=red]'[/color]1_1[color=red]'[/color])">
@scragarSep 06.2008 — #Try this edited version: function removeElements(){ var ele; for(var i = arguments[0].length-1; i >= 0; i--){ ele = arguments[i] if(typeof ele == 'string'){ ele = document.getElementById(ele); }; try{ ele.parentNode.removeChild(ele); }catch(e){}; }; };
then call it like this:<i> </i> <input type="button" value="Delete" onClick="removeElement('1', '2')">
although it should be noted that elements IDs technicaly shouldn't be allowed to begin with a number.