PDA

View Full Version : How can i get children div property?



jaisonjames
29 Dec 2010, 1:19 AM
I have a div structure live this

<div id="col1">
<div id="someId01"></div>
<div id="someId02"></div>
<div id="someId03"></div>
</div>



Is it possible to get all children elements width, height ,id etc? for parent div (col1)using below code.

Ext.get('col1').select('div').getWidth();

mankz
29 Dec 2010, 1:48 AM
Nope, try something like this:



Ext.select('div').each(function(div) {
console.log(div.getWidth());
});

jaisonjames
29 Dec 2010, 2:37 AM
Not working :(

mankz
29 Dec 2010, 2:39 AM
Works for me, what do you get when you run:



Ext.get('col1').select('div').each(function(div) {
console.log(div.getWidth());
});

jaisonjames
29 Dec 2010, 2:49 AM
Thanks mankz (http://www.sencha.com/forum/member.php?17197-mankz). Now working fine. :)

One simple question
Need only first child's (div) property No need the property of nested child elements. Any solution?

mankz
29 Dec 2010, 3:11 AM
Ext.get('col1').select('>div').each(function(div) {
console.log(div.getWidth());
});

jaisonjames
29 Dec 2010, 3:17 AM
Excellent !!! Thank you very much mankz :)

jaisonjames
29 Dec 2010, 9:15 PM
Unfortunately not getting children ID, I have using getId() and getItemId (http://dev.sencha.com/deploy/dev/docs/output/Ext.BoxComponent.html)()

Any other solution?

Thanks

jaisonjames
29 Dec 2010, 10:17 PM
Unfortunately not getting children ID, I have using getId() and getItemId (http://dev.sencha.com/deploy/dev/docs/output/Ext.BoxComponent.html)()

Any other solution?

Thanks

mankz
29 Dec 2010, 11:23 PM
try just



div.id

jaisonjames
29 Dec 2010, 11:55 PM
working Fine!!!. You are great :)


try just



div.id