How to passing 'event' value from html file to js file. because in js, its not defined the event and openFile variable.
Html file:
<form>
<input type='file' id="poem" accept='text/plain' onchange='openFile(event)' >
</form>
js file:
function printPoem(event) {
var openFile = function(event) {
var input = event.target;
var reader = new FileReader();
reader.onload = function() {
var text = reader.result;
}
}
}
您需要通过HTML传递this
,例如:
<form> <input type='file' id="poem" accept='text/plain' onchange='openFile(this)'></form>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.