Hatena::Groupmoz-addon

there.is.only.memo

 | 

2008-03-06

Element Traversal を JS で

15:03

実はもう既にもうあった

以下は私の車輪の再発明バージョン

Element.prototype.__defineGetter__("firstElementChild", function() {
   var fChild = this.firstChild;
   while (fChild && fChild.nodeType != 1) // 1 <= Node.ELEMENT_NODE
      fChild = fChild.nextSibling;
   return fChild;
});

Element.prototype.__defineGetter__("lastElementChild", function() {
   var lChild = this.lastChild;
   while (lChild && lChild.nodeType != 1) // 1 <= Node.ELEMENT_NODE
      lChild = lChild.previousSibling;
   return lChild;
});

Element.prototype.__defineGetter__("previousElementSibling", function() {
   var pSibling = this.previousSibling;
   while (pSibling && pSibling.nodeType != 1) // 1 <= Node.ELEMENT_NODE
      pSibling = pSibling.previousSibling;
   return pSibling;
});

Element.prototype.__defineGetter__("nextElementSibling", function() {
   var nSibling = this.nextSibling;
   while (nSibling && nSibling.nodeType != 1) // 1 <= Node.ELEMENT_NODE
     nSibling = nSibling.nextSibling;
   return nSibling; 
});

Element.prototype.__defineGetter__("childElementCount", function() {
   var i = 0;
   var child = this.firstElementChild;
   while (child) {
      i++;
      child = child.nextElementSibling;
   }
   return i;
});

ManiaMania 2012/05/01 09:44 I replied to you in antheor comment about the custom tagger. Anyway I only play .net so scripts are only tested for there. You will need to take script and post in tw externals and see if someone can help you make it work for the french server.

wpwxuvjwpwxuvj 2012/05/02 01:27 z8EC3W <a href="http://dgxmyjcrodoy.com/">dgxmyjcrodoy</a>

csfyomcsfyom 2012/05/02 22:25 Sqj2Nx , [url=http://rgscamfycopc.com/]rgscamfycopc[/url], [link=http://zffhjeukjxlt.com/]zffhjeukjxlt[/link], http://lpypiaceheox.com/

gfqsffsdgfqsffsd 2012/05/03 02:48 S3iPYJ <a href="http://kcahkfppeexe.com/">kcahkfppeexe</a>

wuvprcewuvprce 2012/05/04 01:28 CuUkHz , [url=http://fjwtmsdbnwan.com/]fjwtmsdbnwan[/url], [link=http://cryiqnnynlzz.com/]cryiqnnynlzz[/link], http://sntflkqyauul.com/

ゲスト



トラックバック - http://moz-addon.g.hatena.ne.jp/takenspc/20080306
 |