1

How do I open a file dialog box on hover of an upload button using jQuery of JavaScript?

When I do the same thing with on click of the upload button it's working.

I want do this think on React. Is there is any npm package for React?

This is the code I am trying to do.

<!DOCTYPE html>
<html>
    <head>
        <title>test</title>
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
    </head>

    <body>
        <input type="file" name="file" id="upload"/>
        <input type="button" id="Uplad_button" name="upload_file" value="upload" />

    </body>
</html>

<script type="text/javascript">
    $(document).ready(function(){
      $('#Uplad_button').hover(function(){
        console.log("hover")
        $('#upload').click();
      });
      $('#Uplad_button').click(function(){
        console.log("click")
        $('#upload').click();
      });
    });
</script>
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131

0 Answers0