jQuery:元素显示时如何调用函数 [英] jQuery: How to call function when element shows

查看:139
本文介绍了jQuery:元素显示时如何调用函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在div显示(在显示之后)时调用一个函数.

I want to call a function when a div shows (after show).

有人知道我该怎么做吗?我尝试使用类似的东西:

Does anybody knows how could I do this? I try to use something like that:

$(#someDiv).bind('show',function(){
    alert('example')
});

但是我不确定我是否以正确的方式做到这一点,或者是否有可能实现这一目标.有什么想法吗?

But I don't sure if I do that from correct way or if it is possible or not achieve that. Any ideas?

推荐答案

jQuery live

从jQuery 1.7开始,不推荐使用 .live()方法.使用.on()附加事件处理程序.较早版本的jQuery的用户应优先使用.delegate()而不是.live().

As of jQuery 1.7, the .live() method is deprecated. Use .on() to attach event handlers. Users of older versions of jQuery should use .delegate() in preference to .live().

这篇关于jQuery:元素显示时如何调用函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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