JQuery "change" event

So, I recently took a close look at JavaScript and jQuery and after that came across a Firefox extension called Greasemonkey.

Ok, let me explain what I mean with "modifiy" -event: I have 2-3 custom scripts for a specific page that automatically looks to see if the page has changed in any way and if there is, they load a new one content and add it to the already loaded page (they modify the DOM).

So my accounting text should know when this will happen, but I don't know how. Are there any jQuery events for this? Help would be appreciated.

0


a source to share


2 answers


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();
}

      



+1


a source


With jQuery events, if you want the event to apply to new elements, you must use . the live , but jQuery 1.3 is not events blur

, focus

, mouseenter

, mouseleave

, change

or submit

as live events, and change

- you want to use. ( change

, submit

and blur/focus

are in the roadmap for jQuery 1.4)



Alternatively, you can use the liveQuery plugin .

0


a source







All Articles