Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

change profile photo with javascript

//ui
<form action="" method='post'>
  <img src="https://www.freeiconspng.com/uploads/no-image-icon-13.png" id="coverPreview" alt="">
  <input type="file" id="cover" />
</form>

//css
input{
  display:none;
}

//js
 let coverPreview = document.getElementById('coverPreview');
        let cover = document.getElementById('cover');

        coverPreview.addEventListener('click',_=>cover.click());

        cover.addEventListener("change",_=>{
            let file = cover.files[0];
            let reader = new FileReader();
            reader.onload = function (){
                coverPreview.src = reader.result;
            }
            reader.readAsDataURL(file);
        });
Comment

PREVIOUS NEXT
Code Example
Javascript :: get character length javascript 
Javascript :: electron iframe require is not defined 
Javascript :: jquery parsexml get attribute 
Javascript :: jquery get id of 3rd parent 
Javascript :: numeros que mais se repetem em um array 
Javascript :: sortingDataAccessor 
Javascript :: angular 11 export excel with customize header 
Javascript :: js insert a point each three digit 
Javascript :: How to Check for an Empty String in JavaScript with the length Property 
Javascript :: while loop vs for loop javascript 
Javascript :: mongoose search multiple fields 
Javascript :: javascript get all elements of an id 
Javascript :: jsx else if statement 
Javascript :: supertest formdata 
Javascript :: recursive function scheme 
Javascript :: js edit browser back location 
Javascript :: reducer function redux 
Javascript :: javascript display, show properties of object 
Javascript :: cai nodejs ubuntu 
Javascript :: open link in a new tab progmatically 
Javascript :: vuejs input call the value 
Javascript :: private methods js 
Javascript :: Getting Search Parameters From A URL As An Array 
Javascript :: Reactjs cant find serviceWorker.js file in app src folder 
Javascript :: reac native play sound 
Javascript :: jvectormap color regions 
Javascript :: callback hell 
Javascript :: Get async: false 
Javascript :: hot get access_token instead of url 
Javascript :: destructuring object 
ADD CONTENT
Topic
Content
Source link
Name
7+6 =