Home > Web Front-end > JS Tutorial > JS simple implementation of file upload example code (no plug-in required)_javascript skills

JS simple implementation of file upload example code (no plug-in required)_javascript skills

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-05-16 17:14:58
Original
1449 people have browsed it

Copy code The code is as follows:

Please select the file


// Click #selectFile to trigger the click event of input:file
Copy code The code is as follows:

jQuery('#selectFile').live('click',function(){
var ie = !-[1,];
if( ie){
jQuery('input:file').trigger('click').trigger('change');
}else{
jQuery('input:file').trigger(' click');
}

});

The event to be triggered by selecting the file
Copy code The code is as follows:

jQuery('input:file').change(function(){
//dosomthing
});

Note:

1. Under the Chrome browser, for data security, the hidden input: file cannot trigger the "click" event. So you need to set the transparency of input: file to achieve the hidden effect.

2. The input file under IE6 and 7 does not support the onchange event, so I still use

Related labels:
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
Latest Issues
Where is js written?
From 1970-01-01 08:00:00
0
0
0
js file code not found
From 1970-01-01 08:00:00
0
0
0
js addClass not working
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template