0

I have an iframe on my site, in the iframe I put a button to trigger the

<input type="file">

These are the elements:

button id="click"
input type="file" id = "file"

This is the script code:

 $("#click").click(function() {
$('#file').trigger('click');
 });

I also replace the .trigger into .click(); but nothing happens

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
rekcah101
  • 27
  • 2
  • 10

1 Answers1

1

Just remove commas.Try like this

assign button id="click1"

 $("#click1").click(function() {
$("input").trigger('click');
 });
Anish
  • 2,889
  • 1
  • 20
  • 45
  • tnx.., but my original code dont really have a comma:, this is my origginAL code $("#click, #click label").click(function() { $('#file').trigger('click'); }); – rekcah101 May 16 '11 at 03:18
  • ive found this post.., http://stackoverflow.com/questions/210643/in-javascript-can-i-make-a-click-event-fire-programmatically-for-a-file-input-e – rekcah101 May 16 '11 at 03:35
  • it works fine on fire fox....just paste above code inside body tag after the – Anish May 16 '11 at 03:43