ExtJS Learning--------ext.element Query Method Learning (example)

Source: Internet
Author: User


Specific examples: (experimental results can be copied code after the demonstration)

Ext.onready (function () {ext.create (' Ext.panel.Panel ', {//Create a panel title: ' My panel ', Width: ' 100% ', height:400, Renderto: Ext.getbody (), HTML: ' <div id=d1><span id=sp> I'm SP content </span><div id=d2> I'm D2 content </div> </div> ');//query system The most common method://ext.dom.element get fly Getdomvar D1 = ext.get (' D1 '); var sp = ext.get (' SP ');//Query system method://1 : Contains: Determines whether the element contains another element alert (D1.contains (SP)), Alert (d1.contains (' SP ')),//2:child: Selects the element that matches the selector from the immediate child element of the element ( Returns only one element, and cannot return an array), 2 parameters The second parameter is optional if true means that the htmlelement element var ch1 = d1.child (' span ') is obtained, and//ext.dom.elementalert ( Ch.dom.innerHTML) var CH2 = D1.child (' span ', true);//htmlelementalert (ch.innerhtml);//3:down: Select the child element of the element that matches the selector// Findparentnode, up: Finds the parent element of the element that matches the simple selector var ch1 = d1.down (' #d2 '); alert (Ch1.dom.innerHTML);//4:first: Select the first child element of an element// Last: Select the final child element of the element var F1 = D1.first (' div '); alert (F1.dom.innerHTML);//5:findparent: Finds the parent element of the element that matches the simple selector// Parent: Returns the element's parents as var = sp.findparent (' div '), alert (parent.innerhtml),//6:is: Determines whether the element matches the selector alert (d1.is (' div '));/7:next: Select the next element in the same layer of the element//prew: Select the element on the same layer as the previous element var next = Sp.next (); alert (next.dom.nodeName);//8:ext.query: Gets the element according to the selector ( Ext.dom.Element.query) var arr = ext.query (' span ', ' D1 ');//htmlelement[]ext.array.each (arr, function (item) {Alert ( item.innerhtml);}); /9:ext.select/ext.dom.element.select: Gets the collection of elements based on the selector//Returns the element collection: Ext.dom.CompositeElementLite (HTMLELEMENNT)/ Ext.dom.CompositeElement (Ext.dom.Element)//Parameter description: 3 parameters,//1:selector selector (do not use ID selector)//2: Returns the Collection Object (Boolean false: Ext.dom.CompositeElementLite true:Ext.dom.CompositeElement)//3: Specify the root node start lookup///parameter is false when var list1 = ext.select (' span ' , false, ' D1 ');//ext.dom.compositeelementliteext.array.each (List1.elements,function (EL) {alert (el.innerhtml);}); /parameter is true when var list2 = ext.select (' span ', true, ' D1 ');//ext.dom.compositeelementext.array.each (List2.elements, Function (EL) {alert (El.dom.innerHTML);});});



ExtJS Learning--------ext.element Query Method Learning (example)

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.