Home > Web Front-end > HTML Tutorial > Use trigger method to pop up file selection dialog box without clicking file type input_HTML/Xhtml_Web page production

Use trigger method to pop up file selection dialog box without clicking file type input_HTML/Xhtml_Web page production

WBOY
Release: 2016-05-16 16:39:20
Original
1214 people have browsed it

You can use the trigger method. There is no native trigger function in JavaScript. You can write one yourself, or you can directly use the jquery implementation:

Copy code
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 way, which is to cover the image or hyperlink or other div to be clicked with the input, and then set the input Make it completely transparent, so that when you click on the picture, you actually click on the input, as follows:

Copy the code
The code is as follows:



< ;/div>
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template