Dojo Learning notes 7. Dojo.dom

Source: Internet
Author: User
Tags unique id

Module: Dojo.dom

Dojo.dom.isNode

Tests whether the specified object is a node

Usage Example:

dojo.dom.isNode(dojo.byId('edtTitle'));
dojo.dom.getUniqueId

Get a unique ID

Usage Example:

dojo.dom.getUniqueId(); //will return dj_unique_#
dojo.dom.firstElement = dojo.dom.getFirstChildElement

Gets the first child node under the specified node that satisfies the specified tag condition

Usage Example:

dojo.dom.firstElement(parentNode, 'SPAN');
dojo.dom.lastElement = dojo.dom.getLastChildElement

Gets the last child node under the specified node that satisfies the specified tag condition

Usage Example:

dojo.dom.lastElement(parentNode, 'SPAN');
dojo.dom.nextElement = dojo.dom.getNextSiblingElement

Gets the next child node that satisfies the specified tag condition for the specified node

Usage Example:

dojo.dom.nextElement(node, 'SPAN');
dojo.dom.prevElement = dojo.dom.getPreviousSiblingElement

Gets the child node of the specified node that satisfies the specified tag condition

Usage Example:

dojo.dom.prevElement(node, 'SPAN');
dojo.dom.moveChildren

Moves all child nodes under the specified node to the target node and returns the number of nodes moved

Usage Example:

dojo.dom.moveChildren(srcNode, destNode, true);//仅移动子节点,srcNode中的文字将被丢弃
dojo.dom.moveChildren(srcNode, destNode, false);//包括文字和子节点都将被移动到目标节点下
dojo.dom.copyChildren

Copies all child nodes under the specified node to the target node and returns the number of replicated nodes

Usage Example:

dojo.dom.moveChildren(srcNode, destNode, true);//仅复制子节点,srcNode中的文字将被忽略
dojo.dom.moveChildren(srcNode, destNode, false);//包括文字和子节点都将被复制到目标节点下
dojo.dom.removeChildren

Deletes all child nodes under the specified node and returns the number of nodes deleted

Usage Example:

Dojo.dom.moveChildren (node);

Dojo.dom.replaceChildren

Replaces all child nodes under the parent node with the specified new node

Usage Example:

dojo.dom.replaceChildren(node, newChild); //目前还不支持newChild为数组形式
dojo.dom.removeNode

Deletes the specified node

Usage Example:

dojo.dom.removeNode(node);
dojo.dom.getAncestors

Returns the collection of parent nodes for the specified node

Usage Example:

dojo.dom.getAncestors(node, null, false);//返回所有的父节点集合(包括指定的节点node)
dojo.dom.getAncestors(node, null, true);//返回最近的一个父节点
dojo.dom.getAncestors(node, function(el){/* 此处增加过滤条件 */return true}, false);//返回所有满足条件的父节点集合
dojo.dom.getAncestorsByTag

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.