2.x YAHOO.util.??? | 3.0 |
---|---|
Dom.get('elementId'); | Y.one('#elementId'); |
Dom.getElementsBy(someFilterFunction); | myNode.all('selectorString'); |
Dom.getElementsByClassName('highlight'); | myNode.all('.highlight'); |
Dom.getChildren(el); | myNode.get('children'); |
Dom.getChildrenBy(someFilterFunction); | myNode.all('selectorString'); |
Dom.getFirstChild(parentEl); | myNode.one('*'); |
Dom.getFirstChildBy(someFilterFunction); | myNode.one('> selectorString'); |
Dom.getLastChild(el); Dom.getLastChildBy(someFilterFunction); | myNode.get('children').slice(-1).item(0); // OR target the node with a selector myNode.one('> selector:last-of-type'); |
Dom.getNextSibling(el); Dom.getNextSiblingBy(someFilterFunction); Dom.getPreviousSibling(el); Dom.getPreviousSiblingBy(someFilterFunction); | myNode.next(); myNode.next('selectorString'); myNode.previous(); myNode.previous('selectorString'); |
Dom.getAncestorBy(someFilterFunction); Dom.getAncestorByClassName('highlight'); Dom.getAncestorByTagName('pre'); | myNode.ancestor(someFilterFunction); myNode.ancestor('.highlight'); myNode.ancestor('pre'); |
Dom.isAncestor(ancestorEl, el); | ancestorNode.contains(myNode); |
Dom.insertAfter(el, afterEl); Dom.insertBefore(el, beforeNode); | afterNode.insert(myNode, 'after'); beforeNode.insert(myNode, 'before'); |
Dom.addClass('highlight'); | myNode.addClass('highlight'); |
Dom.removeClass(el, 'highlight'); | myNode.removeClass('highlight'); |
Dom.replaceClass(el, 'high', 'low'); | myNode.replaceClass('high', 'low'); |
Dom.hasClass(el, 'highlight'); | myNode.hasClass('highlight'); |
Dom.getStyle(el, 'backgroundColor'); | myNode.getStyle('backgroundColor'); |
Dom.setStyle(el, 'borderColor', '#C0FFEE'); | myNode.setStyle('borderColor', '#C0FFEE'); |
Dom.getXY(el); Dom.getX(el); Dom.getY(el); | myNode.getXY(); myNode.getX(); myNode.getY(); |
Dom.setXY(el, [ 500, 300 ]); Dom.setX(el, 500); Dom.setY(el, 300); | myNode.setXY([ 500, 300 ]); myNode.setX(500); myNode.setY(300); |
Dom.inDocument(el); | myNode.inDoc(); |
Dom.batch(elementArray, Dom.addClass, 'highlight'); | myNodelist.addClass('highlight'); // OR myNodelist.each(function (node) { node.addClass('highlight') }); // OR Y.Array.each(myNodelist, function (node) { node.addClass('highlight'); }); |
Dom.generateId(); | Y.guid(); |
Dom.getViewportHeight(); Dom.getViewportWidth(); | myNode.get('winHeight'); myNode.get('winWidth'); |
Dom.getDocumentHeight(); Dom.getDocumentWidth(); | myNode.get('docHeight'); myNode.get('docWidth'); |
Dom.getClientRegion(); | myNode.get('viewportRegion'); |
Dom.getRegion(el); | myNode.get('region'); |
Dom.getDocumentScrollLeft(); Dom.getDocumentScrollTop(); | myNode.get('docScrollX'); myNode.get('docScrollY'); |
copy from http://yuilibrary.com/yui/docs/node/#node-migration
之所以贴出来是因为实在是太完善了!对了解yui node的使用有很多的帮助!