【发布时间】:2011-08-22 14:12:52
【问题描述】:
// A simple Javascript Object / String
var object = "hello";
// Imagine a button in the DOM, and if it's clicked the object value will change
document.getElementById("button").onclick = function(){
window.object = "hello world";
}
// Now I would like to track and do something when the object is changed, ex:
object.onreadystatechange = function(){
alert(object);
}
注意:这听起来很愚蠢,因为我可以在按钮上的 onclick 事件中获得更改,但这不是我想要的,我想严格跟踪对象本身的更改种使用,上面的代码只是一个例子。
【问题讨论】:
标签: javascript object