PDA

View Full Version : Is there any way to get the div by classname and append a node to it.



tsensuous.grace
20 Jun 2016, 3:58 PM
I want to create a new element div inside a container..something like:<br>
Ext.DomHelper.append('.parentbody', {tag: 'div', cls: 'new-div-cls', id: 'new-div-id'});<br>In the dom it will look like:<br>
&lt;div class="parentbody"&gt;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;div id="new-div"&gt;&lt;/div&gt;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/div&gt;<br><br><br>however im unable to append the child using a class name. I know there are ways out to do with "id"? Can someone help with the syntax to append new created node?<br><br>Thanks

joel.watson
22 Jun 2016, 9:57 AM
Hi-

You could use Ext.dom.Query.select() to retrieve the desired node by selector, and then use that node to do the append().

http://docs.sencha.com/extjs/4.2.4/extjs-build/docs/index.html#!/api/Ext.dom.Query-method-select

Thanks!
Joel