自定义jQuery事件 [英] Custom jQuery event

查看:65
本文介绍了自定义jQuery事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建自己的事件 - OnPositionChange。事件的实施当然不是问题。关键是,当顶部或左侧样式发生变化时如何触发它?我应该覆盖$ .css()函数的原型,还是有更好的解决方案?

I want to create my own event - OnPositionChange. Event implementation of course is not a problem. The point is, how to trigger it when top or left style has changed? Should I overwrite prototype of $.css() function, or is there a better solution?

推荐答案

我正在尝试不同的东西,找到了这样的最佳解决方案:

I was trying diffrent thing and found best solution like this:


$.prototype.css2=$.prototype.css;
$.prototype.css=function( key, value ) {
    console.log(key);
    return this.css2(key,value);
}

要检查大量对象,setInterval会使代码过慢。

With large amount of objects to check setInterval would slow down my code too much.

这篇关于自定义jQuery事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆