<input id="a" type="text" /> <span id="b"></span>
var obj = {}; Object.defineProperty(obj,'txt',{ set:function(val){ document.getElementById('a').value = val; document.getElementById('b').innerHTML = val; } }) document.getElementById('a').addEventListener('input',function(e){ obj.txt = e.target.value; });