[thelist] DOM: previousSibling and LI tags
Christian Heilmann
codepo8 at gmail.com
Thu Jan 19 16:04:28 CST 2006
> var _this=_DOMManager.prototype;
> function _DOMManager(){}
>
> _this.sweep=function(obj){
> if(!obj)obj=document;
> var children=obj.childNodes;
>
> for(var j=0;j<children.length;j++){
> //if node is a text node and it conists of only whitespace
> if(children[j].nodeType==3&&/^\s*$/.test(children[j].nodeValue))
> children[j].parentNode.removeChild(children[j]);
>
> if(children[j])this.sweep(children[j]);
> }
> };
> var DOMManager=new DOMManager();
>
> And after setting all these up. Simply sweep the element preferably at
> window load.
>
> window.onload=function(){
> DOMManager.sweep( document.getElementById("IDOfMyList") );
> };
> Though it's debatable, whether modifying the node tree is a good option or not.
Cor. That is a bit of heavy weaponry to make a previousSibling work...
Especially as it'll happen on every pageload, and not just when it is needed :-)
Nice work though.
--
Chris Heilmann
Blog: http://www.wait-till-i.com
Writing: http://icant.co.uk/
Binaries: http://www.onlinetools.org/
More information about the thelist
mailing list