dojo.NodeList-traverse-- dojo遍历节点列表的操作方法
dojo.NodeList-traverse
Method extensions to dojo.NodeList /dojo.query for traversing the DOM. These methods are intended to match the API naming and behavior as the similarly named methods in jQuery. IntroductionDoing a dojo.require(“dojo.NodeList-traverse”) will add some addition methods to dojo.NodeList (the return object from a dojo.query call) that allow easier traversal of the DOM as it relates to the nodes in the dojo.NodeList. UsageHere is a simple example showing how dojo.NodeList-traverse adds a “children” method to dojo.NodeList that can be called via the normal method chaining done with a dojo.query result:
Methods added by dojo.NodeList-traversechildrenReturns all immediate child elements for nodes in this dojo.NodeList. Optionally takes a query to filter the child elements. .end() can be used on the returned dojo.NodeList to get back to the original dojo.NodeList. Example Assume a DOM created by this markup:
closestReturns closest parent that matches query, including current node in this dojo.NodeList if it matches the query. Optionally takes a query to filter the closest nodes. .end() can be used on the returned dojo.NodeList to get back to the original dojo.NodeList. Example Assume a DOM created by this markup:
parentReturns immediate parent elements for nodes in this dojo.NodeList. Optionally takes a query to filter the parent elements. .end() can be used on the returned dojo.NodeList to get back to the original dojo.NodeList. Example Assume a DOM created by this markup:
parentsReturns all parent elements for nodes in this dojo.NodeList. Optionally takes a query to filter the parent elements. .end() can be used on the returned dojo.NodeList to get back to the original dojo.NodeList. Example Assume a DOM created by this markup:
siblingsReturns all sibling elements for nodes in this dojo.NodeList. Optionally takes a query to filter the sibling elements. .end() can be used on the returned dojo.NodeList to get back to the original dojo.NodeList. Example Assume a DOM created by this markup:
nextReturns the next element for nodes in this dojo.NodeList. Optionally takes a query to filter the next elements. .end() can be used on the returned dojo.NodeList to get back to the original dojo.NodeList. Example Assume a DOM created by this markup:
nextAllReturns all sibling elements that come after the nodes in this dojo.NodeList. Optionally takes a query to filter the sibling elements. .end() can be used on the returned dojo.NodeList to get back to the original dojo.NodeList. Example Assume a DOM created by this markup:
prevReturns the previous element for nodes in this dojo.NodeList. Optionally takes a query to filter the previous elements. .end() can be used on the returned dojo.NodeList to get back to the original dojo.NodeList. Example Assume a DOM created by this markup:
prevAllReturns all sibling elements that come before the nodes in this dojo.NodeList. Optionally takes a query to filter the previous elements. The returned nodes will be in reverse DOM order -- the first node in the list will be the node closest to the original node/NodeList. .end() can be used on the returned dojo.NodeList to get back to the original dojo.NodeList. Example Assume a DOM created by this markup:
andSelfAdds the nodes from the previous dojo.NodeList to the current dojo.NodeList. .end() can be used on the returned dojo.NodeList to get back to the original dojo.NodeList. Example Assume a DOM created by this markup:
firstReturns the first node in this dojo.NodeList as a dojo.NodeList. This method is provided due to a difference in the Acme query engine used by default in Dojo. The Acme engine does not support ":first" queries,since it is not part of the CSS3 spec. This method can be used to give the same effect. For instance,instead of doing dojo.query("div:first"),you can do dojo.query("div").first(). Example Assume a DOM created by this markup:
lastReturns the last node in this dojo.NodeList as a dojo.NodeList. This method is provided due to a difference in the Acme query engine used by default in Dojo. The Acme engine does not support ":last" queries,instead of doing dojo.query("div:last"),you can do dojo.query("div").last(). Example Assume a DOM created by this markup:
evenReturns the even nodes in this dojo.NodeList as a dojo.NodeList. This method is provided due to a difference in the Acme query engine used by default in Dojo. The Acme engine does not support ":even" queries,instead of doing dojo.query("div:even"),you can do dojo.query("div").even(). Example Assume a DOM created by this markup:
oddReturns the odd nodes in this dojo.NodeList as a dojo.NodeList. This method is provided due to a difference in the Acme query engine used by default in Dojo. The Acme engine does not support ":odd" queries,instead of doing dojo.query("div:odd"),you can do dojo.query("div").odd(). Example Assume a DOM created by this markup:
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |