Jquery - 当 div 内容更改时如何启动函数

标签 jquery

我搜索了如下解决方案:

if( content from $('#div') is change -> start function test(); )

我用 $('#div').html('blub'); 更改内容

提前致谢! 彼得

PS:我知道,使用 setTimeout 是可能的,但这是一个非常肮脏的解决方案:/

最佳答案

我认为实现这一点的最佳方法是编写一个自定义 html 函数,如下所示:

function changeHtml(content) {
    this.html(content);
    yourChangeHandler(this);
}

编辑:或者通过更改事件... http://forum.jquery.com/topic/what-is-the-best-way-to-handle-onchange-event-on-a-div

关于Jquery - 当 div 内容更改时如何启动函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3493052/

相关文章:

jquery - 使用 jquery 控制 div 大小

javascript - 如何在文本框中设置值 - asp.net 使用 jquery?

javascript - 在 slider 上暂停视频

php - 父子组合框

jquery - jQuery 插件中的异常处理

javascript - 将变量与按钮绑定(bind)的更有效方法?

jquery - jQuery 可以处理部分元素吗? (范围)

javascript - jQuery attr 方法可以设置点击处理程序和内部文本

jquery - 从 php 脚本中检索 jquery 中的 JSON

javascript - html 中的 jquery 常见问题解答页面中的问题