Javascript Form How to - Prototype input type=file








Question

We would like to know how to prototype input type=file.

Answer


<!DOCTYPE html>
<html>
<head>
<script type='text/javascript'
  src='http://code.jquery.com/jquery-1.9.1.js'></script>
<script type='text/javascript'>
$(window).load(function(){<!--   w ww.  ja v  a2s  .co m-->
    HTMLInputElement.prototype.doStuff = function(){
        console.log('hey');
    }
    var fileElement = document.getElementById('file');
    fileElement.doStuff();
});
</script>
</head>
<body>
  <input type="file" id="file" />
</body>
</html>

The code above is rendered as follows: