是否可以检查是否在jquery中删除了一个类 [英] Is it possible to check if a class is removed in jquery
本文介绍了是否可以检查是否在jquery中删除了一个类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想知道是否删除了一个类.像这样:
I would like to know if a class is removed. something like:
if(.class"已删除),然后{get class.object}
if(".class" is removed) then { get class.object}
我需要知道它,因为我需要删除该类中的对象.
I need to know it, because I need the object in wich the class is being removed.
谢谢
标记
推荐答案
如果您可以确定删除是通过jQuery进行的,请挂钩该方法.
If you can be sure that the removal happens via jQuery, hook the method.
var _oldremove = jQuery.fn.removeClass;
jQuery.fn.removeClass = function() {
if( arguments[0] === 'the_class_you_are_looking_for' ) {
// do something with this === current object
}
_oldremove.apply(this, arguments);
};
请注意,您可能需要覆盖更多的方法,例如.toggleClass
.
Be aware that you might need to overwrite more methods, like .toggleClass
.
这篇关于是否可以检查是否在jquery中删除了一个类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文