Sora
Sora

Reputation: 2551

triggering input file click in IE9

I can't seem to trigger the click event of input file in IE and i don't know what is the problem

<input type="file" class="ruFileInput" />
<button id="clickMe" value="ClickMe" ></button>


<script type="text/javascript">
   $(document).ready(function(){
      $("#clickMe").click(function(){
         $('input[type=file]').trigger('click');
      });
   });

it's working fine on firfox and chrome but not in IE9

Upvotes: 3

Views: 6515

Answers (2)

Hazem Salama
Hazem Salama

Reputation: 15111

Add the closing quotes to the class of the first input and add some text to the button to show properly

Here is a fiddle that worked

Also make sure you are grabbing the jquery files as well in your html

Upvotes: 3

Ben
Ben

Reputation: 73

Just tested the below and it worked fine. You had missed the closing " at the end of class="ruFileInput

I have tested on IE9 and works fine.

<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript">
    $(document).ready(function(){
        $("#clickMe").click(function(){
            $('input[type=file]').trigger('click');
        });
    });
</script>
</head>
<body>
   <input type="file" class="ruFileInput" />
   <button id="clickMe" value="ClickMe" ></button>
</body>
</html>

Upvotes: 2

Related Questions