// 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.getElement
Well you can make it an actual oject with get and set methods:
// A simple Javascript Object
var object = new (function(){
this.text = 'hello';
this.setText = function(msg){
this.text = msg
//on change event
}
})();
// Imagine a button in the DOM, and if it's clicked the object value will change
document.getElementById("button").onclick = function(){
object.setText('New Text');
}
Here is a demo fiddle: http://jsfiddle.net/maniator/BSYpz/