Reputation: 191
I have the following html element:
<input type="file" id="file-selector",onchange="readJson(this)" accept=".txt, .json, "> </input>
and the following function:
function readJson(selector) {
console.log("I'm a sucessful onchange event!")
var fileList = selector.files;
loadJsonAsText(fileList[0]);
}
When I choose a file and open the console I don't see "I'm a sucessful onchange event!", indicating that the function didn't work, how can I fix that?
Upvotes: 1
Views: 54
Reputation: 368
Add a space between id and onchange
<input type="file" id="file-selector" onchange="readJson(this)" accept=".txt, .json, "> </input>
Upvotes: 1