We would like to know how to change what input.value returns.
<!DOCTYPE html>
<html>
<head>
<script type='text/javascript'>
HTMLInputElement.prototype.MyValue = function() {
return this.value + this.value;<!-- ww w. j a va 2 s .c o m-->
};
window.onload = function() {
var input = document.getElementById("i");
console.log(input.MyValue());
};
</script>
</head>
<body>
<input type="text" value="a" id="i" />
</body>
</html>
The code above is rendered as follows: