mozilla
Your Search Results

    Node

    この文書は翻訳中です。他国語のままの部分などがあるのはその為です。
    是非お気軽に MDN に登録して翻訳に参加し、私たちの手助けをして下さい!

    A Node is an interface from which a number of DOM types inherit, and allows these various types to be treated (or tested) similarly.
    The following all inherit this interface and its methods and properties (though they may return null in particular cases where not relevant; or throw an exception when adding children to a node type for which no children can exist): Document, Element, Attr, CharacterData (which Text, Comment, and CDATASection inherit), ProcessingInstruction, DocumentFragment, DocumentType, Notation, Entity, EntityReference

    プロパティ

    メソッド

    定数

    Node.nodeType も参照して下さい。

    名称
    ELEMENT_NODE 1
    ATTRIBUTE_NODE 2
    TEXT_NODE 3
    DATA_SECTION_NODE 4
    ENTITY_REFERENCE_NODE 5
    ENTITY_NODE 6
    PROCESSING_INSTRUCTION_NODE 7
    COMMENT_NODE 8
    DOCUMENT_NODE 9
    DOCUMENT_TYPE_NODE 10
    DOCUMENT_FRAGMENT_NODE 11
    NOTATION_NODE 12
    DOCUMENT_POSITION_DISCONNECTED 0x01
    DOCUMENT_POSITION_PRECEDING 0x02
    DOCUMENT_POSITION_FOLLOWING 0x04
    DOCUMENT_POSITION_CONTAINS 0x08
    DOCUMENT_POSITION_CONTAINED_BY 0x10
    DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC 0x20

    コードスニペット

    Browse all child nodes

    The following function recursively cycle all child nodes of a node and execute a callback function upon them (and upon the parent node itself).

    function DOMComb (oParent, oCallback) {
      if (oParent.hasChildNodes()) {
        for (var oNode = oParent.firstChild; oNode; oNode = oNode.nextSibling) {
          DOMComb(oNode, oCallback);
        }
      }
      oCallback.call(oParent);
    }

    構文

    DOMComb(parentNode, callbackFunction);

    説明

    Recursively cycle all child nodes of parentNode and parentNode itself and execute the callbackFunction upon them as this objects.

    引数

    parentNode
    The parent node (Node Object).
    callbackFunction
    The callback function (Function).

    用例

    The following example send to the console.log the text content of the body:

    function printContent () {
      if (this.nodeValue) { console.log(this.nodeValue); }
    }
    
    onload = function () {
      DOMComb(document.body, printContent);
    };

    仕様書

    ドキュメントのタグと貢献者

    Contributors to this page: ethertank, RobinEgg, khalid32
    最終更新者: khalid32,