Skip to content

Instantly share code, notes, and snippets.

@xiaojue
Created January 17, 2012 08:47
Show Gist options
  • Save xiaojue/1625708 to your computer and use it in GitHub Desktop.
Save xiaojue/1625708 to your computer and use it in GitHub Desktop.
onpropertychange
<html>
<body>
<form name="frmMain">
<input name="fireTarget">
<input type="hidden" name="output">
</form>
<script>
function changeRealElement () {
var torgand = document.frmMain["fireTarget"];
var realElem = document.frmMain["output"];
realElem.value = torgand.value;
console.log(realElem.value);
}
function _onload () {
var torgand = document.frmMain["fireTarget"];
if(window.attachEvent) { // IE
torgand.attachEvent('onpropertychange',changeRealElement);
}else{ // Firfox
torgand.addEventListener('input',changeRealElement,false);
}
}
_onload();
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment