ExtJs - Get element by div class?

烈酒焚心 提交于 2019-12-05 03:30:43

Use

var dom = Ext.dom.Query.select('.abc');
var el = Ext.get(dom[0]); 

This will return an Ext.Element. You can then use ext methods on el like so

el.on('click', function(){}, scope);

or

el.getWidth()

I believe you mean Ext.dom.Element (not ExtJs component object). If yes try this code

var d = Ext.get( "main" );
alert(d.down('.abc').getWidth());​

demo

For Ext4 and up you could use the following:

Ext.ComponentQuery.query('panel[cls=myCls]');

And you will get and array of this components

source: http://docs.sencha.com/ext-js/4-1/#!/api/Ext.ComponentQuery

Ext.select('abc');

This method works in EXT 4 also.

In your example, just remove the dot when calling the string of the class name.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!