Tuesday, 15 February 2011

javascript - Create a setter that updates a dom element with the new value? -


Is there a way to create a setter that changes the property of any object when a DOM element updates it?

I do not believe this. Without making a setter, then x will hang a simple Jane property object, when there will be no change in knowing. Why do you want to avoid Setter? This is a very clear way to accomplish your goal.

But there is a small thing to keep in mind, object.definproperty , although more verbose is more supported, and win set and Get :

  a = {}; Object.defineProperty (a, 'x', {get: function}} set this return._x;} function: (newX) {this._x = newX; $ ("# my_element"). Html (newX); }});    

No comments:

Post a Comment