1Ext.onready (function () {2 3Ext.create (' Ext.panel.Panel ', {4Title: ' My Panel ',5Width: ' 100% ',6height:400,7 renderTo:Ext.getBody (),8HTML: ' <div id=d1><span id=sp> I am SP content </span><div id=d2> I am D2 content </div></div>< Input ID=INP value=123/><form id=f1><input name=uname value=bhx/><input name=pwd value=123/>< /form> '9 });Ten //The most common method of querying is: One //Ext.dom.Element get Fly getdom A - varD1 = ext.get (' D1 ');//It's all ID . - varSP = ext.get (' SP '); the - //Query System method: - - //1:contains: Determines whether an element contains another element + //alert (D1.contains (SP)); - //Alert (d1.contains (' SP ')); + A //2:child: Select the element that matches the selector from the immediate child element of the element (only one element is returned, and the array cannot be returned), and the second parameter of the 2 parameter is optional if True indicates that the original HtmlElement element was obtained at //get the first child element - //var ch1 = d1.child (' span '); - //alert (Ch1.dom.innerHTML); - - //var CH2 = d1.child (' span ', true);//htmlelement, gets the native HtmlElement element - //alert (ch2.innerhtml); in - //3:down: Select the child element of the element that matches the selector//findparentnode, up: Find the parent element of the element that matches the simple selector to + //var ch1 = d1.down (' #d2 '); - //alert (Ch1.dom.innerHTML); the * //4:first: Select the first child element of an element//last: Select the last child element of the element $ //var f1 = d1.first (' div ');Panax Notoginseng //alert (F1.dom.innerHTML); - the //21:49 + //5:findparent: Finds the parent element of an element that matches a simple selector//parent: Returns the parent element of the element A the //var parent = sp.findparent (' div '); + //alert (parent.innerhtml); - $ //6:is: Determines whether an element matches a selector $ //Alert (d1.is (' div '));//judgment is not div selector - - //7:next: Selects the next element in the same layer of the element//prew: Selects the previous element of the element's same layer the //var next = Sp.next (); - //alert (next.dom.nodeName);Wuyi the //8:ext.query: Get elements based on selectors (Ext.dom.Element.query) - Wu //parameters: The element to find, from which element ID to find - vararr = Ext.query ("span", "D1"); AboutExt.Array.each (arr,function(item) { $ alert (item.innerhtml); - }); - - //9:ext.select/ext.dom.element.select: Gets the collection of elements based on the selector A //The return is the collection of elements: Ext.dom.CompositeElementLite (htmlelemennt)/ext.dom.compositeelement (Ext.dom.Element) + //parameter Description: 3 parameters, the //1:selector selector (do not use the ID selector) - //2: Returned Collection Object (Boolean False:Ext.dom.CompositeElementLite true:Ext.dom.CompositeElement) $ //3: The specified root node starts looking up the the //var list1 = ext.select (' span ', false, ' D1 ');//ext.dom.compositeelementlite the //Ext.Array.each (List1.elements,function (EL) { the //alert (el.innerhtml); - // }); in //var list2 = ext.select (' span ', true, ' D1 ');//ext.dom.compositeelement the //Ext.Array.each (List2.elements,function (EL) { the //alert (El.dom.innerHTML); About // }); the the the});
ExtJs007 The most common query methods