I have this HTML which looks like this:
You mean this:
jQuery("input.first").click(function(){
jQuery("input.second").trigger('click');
return false;
});
Add id's to both inputs, id="first" and id="second"
//trigger second button $("#second").click()
jQuery("input.first").click(function(){
jQuery("input.second").trigger("click");
return false;
});
this works fine, but file name does not display anymore.
$(document).ready(function(){ $("img.attach2").click(function(){ $("input.attach1").click(); return false; }); });
Well, you just fire the desired click event:
$(".first").click(function(){
$(".second").click();
return false;
});
If it does not work by using the click()
method like suggested in the accepted answer, then you can try this:
//trigger second button
$("#second").mousedown();
$("#second").mouseup();