Make a button like the "browse" button of a file input field - Javascript jQuery

Javascript examples for jQuery:Form Button

Description

Make a button like the "browse" button of a file input field

Demo Code

ResultView the demo in separate window

<html>
 <head> 
  <meta name="viewport" content="width=device-width, initial-scale=1"> 
  <script type="text/javascript" src="https://code.jquery.com/jquery-1.5.2.js"></script> 
  <script type="text/javascript">
    $(window).load(function(){//from   ww  w.j  a  v  a2s  .  c  o m
$("#btn").click(function(){
$("#upload").click();
});
    });

      </script> 
 </head> 
 <body> 
  <input type="button" id="btn" value="Hi"> 
  <br> 
  <input type="file" id="upload" style="display:none">  
 </body>
</html>

Related Tutorials