The Ext.domhelper component in Sencha Touch makes it easy to append or rewrite elements.
Demo Sample:
Launch:function () {function appenddom () {Ext.DomHelper.append (' My-div ', {id: ' url-list ', tag: ' ul ', //Specify appended element kind CN : [//or children. Use array form to define child elements in an array {tag: ' Li ',, Cn:[{tag: ' A ', HTML: ' Google ', href: ' http://www.google.com '}]},{tag: ' Li ', Cn:[{tag: ' A ',// ... Omitted}]})}); var Mytoolbar = ext.create (' Ext.toolbar ', {docked: ' Top ', Items:[{xtype: ' button ', text: ' Append element ', handler:function () { Appenddom ();}}]}); var mypanel = ext.create (' Ext.panel ', {id: ' Mypanel ', HTML: ' <div id= ' my-div ' ></div> ', Items:[mytoolbar]}); Ext.Viewport.add (Mypanel);}
In addition to append, the ability to use the overwrite function to rewrite the contents of an element
Append and delete elements at the specified location, with the following method:
Innsertafter: appending elements after the target element
Innsertbefore: appending elements before the target element
Ext.domquery: Look for elements that can be selected using the CSS selector, such as:
Ext.DomQuery.select (' [class*= ' d '] ')// Select the element with class D
Ext.each: traversal of all appended elements
Ext.removenode: Deleting the specified element
Demo Sample:
var elems = Ext.DomQuery.select ('. Add ');
Ext.each (Elems,function (item,index,array) {//function : Current processing element, current processing element subscript, processing set;elems For the collection to be processed
Ext.removenode (item);
})
The meaning of the above code is: Delete all appended class named add element
HTML5 developing mobile Web Apps--sencha Touch (7)