You can use the trigger method to achieve this without clicking the file-type input pop-up file selection dialog box. Because javascript does not have a native trigger function, you have written one by yourself, if you like it, you can refer to the trigger method. javascript does not have a native trigger function. You can write one by yourself or directly use jquery to implement it:
The Code is as follows:
Var button1 = document. getElementById ("button1 ");
Var button2 = document. getElementById ("button2 ");
Button1.onclick = function () {alert ("button1"); trigger (button2, "onclick ");}
Button2.onclick = function () {alert ("button2 ");}
Function trigger (ele, event)
{Ele [event] ();}
You can also use a simpler method, that is, overwrite the input to the image to be clicked, hyperlink, or other p, and set the input to completely transparent, in this way, when you click an image, the input is actually clicked as follows:
The Code is as follows: