jQuery“修改”事件 [英] jQuery "modify" event

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

问题描述

所以我最近仔细看了一下JavaScript和jQuery,之后绊倒了Firefox扩展名为Greasemonkey。

So I recently took a closer look at JavaScript and jQuery and after that stumbled over the Firefox extension called Greasemonkey.

嗯,让我解释一下我的意思modifiy-event:我已经安装了一些特定页面的2-3个用户脚本,自动查看页面是否以任何方式进行了更改,如果有的话,它们会加载新的内容并将其附加到已加载的页面修改DOM)。

Well, let me explain what I mean with the "modifiy"-event: I've got 2-3 userscripts for a certain page installed which automatically look if the page has changed in any way and if it has, they load the new content and append it to the already loaded page (they modify the DOM).

所以基本上,我的userscript需要知道什么时候发生,但我不知道该怎么做。是否有任何jQuery事件?帮助将不胜感激。

So basically, my userscript needs to know when that happens but I don't know how I should do that. Are there any jQuery events for that? Help would be appreciated.

推荐答案

var orig;

$(function(){
     orig = getContent();
})

function watchContent() {
     var mod = getContent();
     if (mod != orig){ resetContent(orig); }
     setTimeout(watchContent,1000)
}

function resetContent(html) {
  $("body").append( html );
}

function getContent() {
    return $("body").html();
}

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

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