简体   繁体   English

ExtJS获取类名

[英]ExtJS get class name

I have a listener which should change the class on mouseover event. 我有一个侦听器,应在mouseover事件上更改类。

listeners: {
    mouseover: function() {
        this.removeCls(?); //get existing class name
        this.addCls('CAButtonHover');
    },
}

How can I get the existing class name and replace it with a new one? 如何获得现有的类名并将其替换为新的类名? I use ExtJS 6. 我使用ExtJS 6。

If there is no need to have a reference to the existing classes and replace them all with the CAButtonHover class, you can use the setCls method. 如果不需要引用现有类并将其全部替换为CAButtonHover类,则可以使用setCls方法。

this.setCls('CAButtonHover');

But this is not how a hover class is usually implemented. 但这不是通常实现悬浮类的方式。 You add the class alongside existing classes on mouseover and remove it on mouseleave . 您可以在mouseover上将类与现有类一起添加,并在mouseleave上将其删除。 Just make sure you have a higher CSS specificity on the hover class selector so that the hover rules get applied. 只要确保您在悬停类选择器上具有更高的CSS专用性,就可以应用悬停规则。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM