84669 人學習
152542 人學習
20005 人學習
5487 人學習
7821 人學習
359900 人學習
3350 人學習
180660 人學習
48569 人學習
18603 人學習
40936 人學習
1549 人學習
1183 人學習
32909 人學習
我知道 input type=‘file’可以做到。 但是我看一些網站是用p綁定一個事件做到的,不知道是怎麼實現的。
温故而知新,可以为师矣。 博客:www.ouyangke.com
親,這個好辦,你綁定p click事件,再click 隱藏的input[file]的輸入框!
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Demo</title> <script> function showResurce() { document.getElementById('resurce').click(); } </script> </head> <body> <p onclick="showResurce()">点我</p> <input id="resurce" type="file" style="display: none"> </body> </html>
一個方案是,有個隱藏的input file在其它地方,點p後觸發它。
親,這個好辦,你綁定p click事件,再click 隱藏的input[file]的輸入框!
一個方案是,有個隱藏的input file在其它地方,點p後觸發它。