jQuery 中的 onHide() 类型事件 [英] onHide() type event in jQuery

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

问题描述

有人知道 onHide() 事件或 jQuery 中的类似事件吗?

Does anyone know of an onHide() event or something similar in jQuery?

我试过了:

$(this).bind('hide', function(){
    console.log('asdasda')
})

但显然这行不通.


只是为了澄清,它使用 CSS display:none 隐藏.
我知道回调函数,但由于我没有隐藏它(CSS 是),我无法使用它.对于它的价值,我需要检查下拉菜单何时可见.它由以下 CSS 显示:


Just to clarify, it's being hidden using CSS display:none.
I'm aware of the callback function but as I'm not hiding it (the CSS is) I can't use it. For what it's worth, I need to check when a dropdown is visible. It's being shown by the following CSS:

ul li:hover ul {
    display: block;
} 

推荐答案

DOM 中的任何 HTML 元素都没有隐藏"事件.你如何隐藏"你的元素?您是否使用 CSS 来更改显示或可见性?

There is no "hide" event for any HTML element in the DOM. How are you "hiding" your elements? Are you using CSS to change the display or visibility?

如果您使用 display:none 隐藏元素,则无法检测 CSS 何时更改.在 IE 中,您可以检测属性何时发生更改,但不会扩展到样式值.您需要在 CSS 显示更改时抛出一个事件或执行该事件正在执行的任何操作.

If you're using display:none to hide an element, you can't detect when CSS changes. In IE, you can detect when a property changes but that doesn't extend to style values. You'll need to throw an event or do whatever the event is doing at the time the CSS display is changed.

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

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