JavaScript: Difference between revisions

518 bytes added ,  4 February 2020
Line 3: Line 3:


==Usage==
==Usage==
===Inputs===
====Showing an input image====
<syntaxhighlight lang="javascript">
const myInput = document.getElementById("myInput");
const myImage = document.getElementById("myImage");
myInput.addEventListener('change', function() {
    if (myInput.files.length !== 1) {
        return;
    }
    let image = myInput.files[0];
    const reader = new FileReader();
    reader.onload = function(e) {
        myImage.src = e.target.result;
    };
    reader.readAsDataURL(image);
});
</syntaxhighlight>
===Canvas===
===Canvas===
===Picture===
===Video===
===Video===
Your HTML:
Your HTML: