The code below may be useful using jquery.
Be careful it's not thread safe.
To make it thread safe you could use an Array, add the changed elements in, and process the elements using an indexer that you can increment when you process for the changed elements ends. So, the indexer not always will point to the last element (it's only an idea).
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script src="Scripts/jquery-1.4.1.js" type="text/javascript"></script>
<script language="javascript" type="text/jscript">
// set the function OnChanged for the change event
$('*').change(OnChanged);
// global var
var previousText = '';
function doSomeChange(idElement) {
// Save the prev text. Be careful global var is not the best way to do it
// When another process could access it the correct value could have been changed
previousText = $(idElement).text();
// chage the text
$(idElement).text('this text is changed using javascript');
// raise event change
$(idElement).change();
}
//this function will be called when change event of any element will be raised
function OnChanged() {
alert('Text changed, text was ' + previousText);
}
</script>
<title></title>
</head>
<body>
<p id="TestP">Hello, this is dummy text
<a href="javascript:doSomeChange('#TestP')">Do change</a></p>
</body>
</html>